简体   繁体   English

Android - 存储下载内容的位置,内部存储与外部存储?

[英]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? 如果应用程序安装在SDCARD上(因为我的配置是),那么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? 因此,如果我的SDCARD安装的应用程序下载了100MB的内容到内部存储,那么它实际上是在SDCARD上结束了,还是最终在设备的物理板载存储中?

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? 如果应用程序安装在SDCARD上,并且带有下载内容的“内部”存储器位于SDCARD上,那么它是以开放格式物理存储还是加密? I seem to remember reading that an application stored on an SDCARD is encrypted. 我似乎记得读过存储在SDCARD上的应用程序是加密的。 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) (删除有关将文件存储在单个目录中的问题,如Context.getDir()意味着可以在内部存储中创建和维护目录系统)

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: 做了一堆实验,并在摩托罗拉Droid 2上使用Android 2.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. 当应用程序安装/移动到SDCARD时,它将作为.asec文件存储在SDCARD上隐藏的/.android_secure目录中。 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. 当应用程序在“内部存储器”中创建数据文件时,它们存储在设备的内部存储器中, 而不是存储在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 应用程序的“设置/管理应用程序”详细信息对话框具有“数据”的值 - 这是应用程序在其内部存储中使用的数据量,即内部存储器中不在SDCARD上的数据量
  • The external storage does end up on the SDACRD under the /Android/data directory 外部存储最终会在/ Android / data目录下的SDACRD上运行
  • 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. 将我的小应用程序存储在SDCARD上几乎没有什么实际价值,因为它将在手机上消耗的大部分存储将位于设备的内部存储器中。 Except of course that its always good to allow the application to install on the SDCARD. 当然,除了允许应用程序安装在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. 在内部存储器中存储唯一安装ID的概念很有效,直到用户删除应用程序的数据,从而导致计算新的安装ID。 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. 因此,为了能够记住已经下载到设备的内容,需要用户在中央服务器上创建/登录应用程序从头开始的用户帐户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM