开发者

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 appl开发者_如何学JAVAy 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?


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜