Android Download Zip to SD card? -
I have a 100 meg zip file that I need to download when the app starts first. It has to be opened with the SD card (400 megapixels).
I do not need to touch the phone's storage, because on the phone's storage, 400mg will not be free in many phones.
Can it be done (any one example?)
thanks, Ian
can be done What exactly are you looking for? Regular downloads or how to check? Here is the download method, so you should run it in an AsyncTask either.
/ ** * This locals * downloads a remote file and stores to download @param from the remote URL of the file * Where to store the file * the ultimate for local path (For string from string) @throws Exception Read / Write Exceptions * / Fixed Private Zero DownloadFile Exception {HttpURLConnection Conn = (HttpURLConnection) throws new URL .openConnection (); Conn.setDoInput (true); Conn.setConnectTimeout (10000); // timeout 10 seconds conn.connect (); InputStream input = conn.getInputStream (); FileOutputStream fOut = New FileOutputStream (to); Int byteCount = 0; Byte [] buffer = new byte [4096]; Int BitesRad = -1; While ((BytesRed = Input. Read (buffer))! = -1) {fOut.write (buffer, 0, bytes read); ByteCount + = Read Bytes; } Fout.flush (); FOut.close (); }
You may also want to check whether the phone is connected to at least WiFi (and 3G);
// Check for WiFi or 3G ConnectivityManager MgrConn = (connectivity manager) getSystemService (reference. CONNECTIVITY_SERVICE); Telephony Manager mgrTel = (Telephony Manager) System System (Referred TELEPHONY_SERVICE); If ((mgrConn.getActiveNetworkInfo () = Null & amp; amp ;. mgrConn.getActiveNetworkInfo () getState () == NetworkInfo.State.CONNECTED) || mgrTel.getNetworkType () == TelephonyManager.NETWORK_TYPE_UMTS). . <
Comments
Post a Comment