File storage location on device SD

enonod

Well-Known Member
Licensed User
I am confused (when aren't I?) about file storage locations which may be down to loose? terminology.
File.DirInternal / File.DirInternalCache
These two folders are stored in the main memory and are private to your application. Other applications cannot access these files.
The cache folder may get deleted by the OS if it needs more space.

File.DirRootExternal
The storage card root folder.

File.DirDefaultExternal
The default folder for your application in the SD card.
My understanding is that the device usually has memory (Ram) and internal storage (memory not disk drive) organised as SD (internal).
The above description does not 'seem' to distinguish between memory and internal SD.
Because I wish to store files on SD (internal) in case there is not an SD (external) fitted (which I know I can test for), I have been unable to determine if the reference above...
These two folders are stored in the main memory
...should actually say "SD (internal)" rather than give the impression it is "Ram" being used by the app, simply because I have been unable to locate such folders or my app on SD (internal), there seems to be some 'apparent' duplication in folder names surrounding accessing SD (internal).

Will somebody please make it clear to me where my app is internally stored and where my data files will be stored (internally) so that I may find them. Does DirExternal mean external to Ram or external to the normal total memory internal i.e. SD (external)?
 
Last edited:

agraham

Expert
Licensed User
From the Android docs.

File.DirRootExternal
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.
DirDefaultExternal returns the path "/Android/data/" & yourpackageName & "/files/" in DirRootExternal. DirRootExternal is shared by all programs on the device.

File.DirInternalCache
Returns the absolute path to the application specific cache directory on the filesystem. These files will be ones that get deleted first when the device runs low on storage. There is no guarantee when these files will be deleted. Note: you should not rely on the system deleting these files for you; you should always have a reasonable maximum, such as 1 MB, for the amount of space you consume with cache files, and prune those files when exceeding that space.
In devices with a removable SD card for external storage this is located in internal storage of some sort so as to always be available.

File.DirInternalCache
Returns an absolute a directory that is private to your application only. The data you write is directly stored in this directory and is not accessible by any other application. It holds your application files.
In devices with a removable SD card for external storage this is located in internal storage of some sort so as to always be available.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Thank you very much for your time and, as always, precise location of what is required.

I have assumed the word cache should not appear above the final quote.
I have assumed that by 'storage of some sort' that it is irrelevant to know that, probably because...
...and is not accessible by any other application.
...other application includes a file explorer, because I cannot find any directory, as I can with 'DirDefaultExternal', on the path you have indicated.

I would be obliged for a link to these particular Android Docs which I assume contains a wealth of information that might save me asking.
 
Upvote 0

agraham

Expert
Licensed User
I would be obliged for a link to these particular Android Docs which I assume contains a wealth of information that might save me asking.
They are from the individual method documentation in the Android Environment and Context classes. The method names do not necessarily map directly to Basic4android names.

You can read Saving Files | Android Developers
 
Upvote 0

enonod

Well-Known Member
Licensed User
Thank you very much.
 
Upvote 0

Shadow&Max

Active Member
Licensed User
This question has been moved to a new post as per Erel's suggestion...
 
Last edited:
Upvote 0
Top