Srinivas
Srinivas

Reputation: 1736

Way to save application cache in internal sdcard in android?

In my application , downloading lot of files from server. I want to cache them in sdcard. for that am using fallowing api..

context.getExternalCacheDir();

But problem is that, not able to save them in internal sdcard(i.e; non removable external storage).They are saving in to "/mnt/sdcard/external_sd/Android/data/".

Please gimme a way to save may files in to non removable android cache.

Regards, Srinivas

Upvotes: 1

Views: 5648

Answers (1)

pollifax
pollifax

Reputation: 51

From intellisense for Environment.getExternalStorageDirectory:

"Gets the Android external storage directory. This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened. You can determine its current state with getExternalStorageState().

Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.

In devices with multiple "external" storage directories (such as both secure app storage and mountable shared storage), this directory represents the "primary" external storage that the user will interact with.

Applications should not directly use this top-level directory, in order to avoid polluting the user's root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir, which the system will take care of deleting if the application is uninstalled. Other shared files should be placed in one of the directories returned by getExternalStoragePublicDirectory(String)."

Upvotes: 1

Related Questions