Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android – Where to store downloaded content, internal versus external storage?

A number of separate, but related, questions concerning where to store downloaded content within my application.

I have an application that downloads content from a central server. This content is sometimes premium content, or at least content where the publisher does not want it freely distributed. I understand that the “external” storage is readily accessible whereas the “internal” storage is protected, unless the phone is rooted.

If the application is installed on the SDCARD (as mine is configured to be) then is the “internal” storage also physically on the SDCARD? Thus if my SDCARD installed application downloads, say, 100MB of content to internal storage then is it actually ending up on the SDCARD, or is it ending up in the device’s physical on-board storage?

If the application is installed on the SDCARD, and the “internal” storage with the downloaded content is on the SDCARD then is it physically stored in an open format or is it encrypted? I seem to remember reading that an application stored on an SDCARD is encrypted. Does this also apply to the “internal” storage?

(Deleted question about storing files in a single directory as Context.getDir() implies that a directory system can be created and maintained in the internal storage)

Is there a better approach?

like image 753
Colin Avatar asked Sep 09 '11 17:09

Colin


People also ask

What is the difference between internal storage and external storage in Android?

In short, Internal Storage is for apps to save sensitive data to which other apps and users cannot access. However, Primary External Storage is part of built-in storage which can be accessed (for read-write) by the user and other apps but with permissions.

What is the difference between internal storage and phone storage?

The Phone Storage (ROM) is simply the memory of a phone used to store apps, files, multimedia etc. While internal memory (RAM) is the memory where the operating system (OS), application programs and data in current use are kept so they can be quickly reached by the device's processor.

How is the use of internal memory better than the use of external memory?

Internal flash memories provide much faster read/write speed as they are well integrated with the processor of the device. For instance Samsung Galaxy S offers 14 MB per second write speed and 19 MB per second read speed.

What is the difference between external and internal memory?

Internal memory, also called "main or primary memory" refers to memory that stores small amounts of data that can be accessed quickly while the computer is running. External memory, also called "secondary memory" refers to a storage device that can retain or store data persistently.


1 Answers

Did a bunch of experimentation and came to the following conclusions with Android 2.2 on a Motorola Droid 2:

  • When an application is installed/moved to the SDCARD then it is stored as an .asec file in the hidden /.android_secure directory on the SDCARD. This is an encrypted and compressed file.
  • When the application creates data files in the "internal storage" they are stored within the internal memory of the device, not on the SDCARD.
  • The Settings / Manage Applications details dialog for the application has a value for "Data" - this is the amount of data the application is using within its internal storage, that is in the internal memory not on the SDCARD
  • The external storage does end up on the SDACRD under the /Android/data directory
  • Clearing the data from the Settings / Manage Applications details dialog does indeed wipe everything, which means that the installed application needs to have enough knowledge/logic to handle the "no data" situation.

My app is a download content app. What this all means to me is that:

  • There is little real value in storing my small app on the SDCARD given that the bulk of the storage it will consume on the phone will be in the device's internal memory. Except of course that its always good to allow the application to install on the SDCARD.
  • The installation package needs to be able to recover the user's downloaded content if it is wiped by the user.
  • The concept of storing a unique installation id in the internal memory works well until a user deletes the application's data and hence causes a new installation id to be computed. Thus to be able to remember what content has been downloaded to a device requires a user account on a central server that the user creates/logs into whenever the application starts from scratch.
like image 117
Colin Avatar answered Oct 01 '22 23:10

Colin