Android: How can i download a file from a URL to asset folder of the app?
13,331
Solution 1
you cannot download files in app's Asset folder. Instead you should use getCacheDir()
(on internal memory) or getExternalCacheDir()
(on SD card, available in Froyo and above) to download and retrieve your files.
Solution 2
File file = new File(getFilesDir(), "sample.jpg");
use this to get an internal app private directory. You can use debug feature to actually see what is the directory it is referring.
Author by
elixir bash
Updated on June 18, 2022Comments
-
elixir bash almost 2 years
When I start running the app in the mobile, it must connect to a URL and download dataset(files) to the app folder of the app..Is this possible? if so please could you show me a sample ?