Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I download a file via default Android Downloader?

How can I download files using Android downloader? (The downloader that WebBrowser is using that too).

I tried something like this :

Intent i = new Intent(Intent.ACTION_VIEW , Uri.parse("MyUrl"));
startActivity(i);

Any better way?

Edit

I am using Android 2.2

like image 380
Kermia Avatar asked Jun 08 '12 14:06

Kermia


People also ask

How do I download files on Android?

Go to the webpage where you want to download a file. Touch and hold what you want to download, then tap Download link or Download image. To see all the files you've downloaded to your device, open the Downloads app.


1 Answers

If you want to download it onto the user's SD card from an URL, you can just open it in the phone's default internet browser.

String url = "https://appharbor.com/assets/images/stackoverflow-logo.png";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

(Code from this question)

The android browser will then start and the file (in this case an image) will be downloaded.

like image 69
Todd Davies Avatar answered Nov 15 '22 16:11

Todd Davies