Reputation: 25
IDE Eclipse Using emulators
I am downloading files from a webservice. I have no problem saving the files to the sdcard. This can then be accessed via a filemanager.
However, if there is no sdcard available I would like to save the files to 'Downloads' on internal storage. I can't seem to get the files to download to 'Downloads' as it would were you downloading from a browser.
I can however manage to save the files in the application directory on internal storage. Eg data/data/com.example.appname/files/.
The problem is this can only be access via the application.
I need the files to be available to the user to view/open after downloaded.
Is this possible? Or will the user have to have an SDCARD?
Upvotes: 1
Views: 569
Reputation: 39836
the find the downloads folder use:
File downloadFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
but just like others mention, if the SD-Card is not there, there's not much you can do about it, just give a warning to the user.
On the link I posted there's good examples on how to check the existence of the directory and availability of it.
Upvotes: 0
Reputation: 7694
This also depends on the device + provider, some are locked so people cannot access their internal storage at all.
So if you want to cater to people without SD card, save in application directory. They cannot access if they don't have root-access. Nothing you can do about this.
This is quite normal behavior.
Best practice is warn users of their options: saving on SD card or internal storage. And mention consequences if you want.
Upvotes: 1