简体   繁体   English

Android文件存储选项-外部+内部

[英]Android File Storage Options - External + Internal

I am making an educational App and want my users to be able to choose which package they want and download only that package to the device. 我正在制作一个教育性应用程序,希望我的用户能够选择所需的软件包并将其仅下载到设备上。 So basically, my App has a "data" folder. 因此,基本上,我的应用程序具有一个“数据”文件夹。 If a user picks a package say "Signals and Systems", my app should download it from a http server to a private location on the device from which my app can then present data to the user. 如果用户选择“ Signals and Systems”(信号和系统)包,则我的应用程序应将其从http服务器下载到设备上的私有位置,然后我的应用程序可以从该私有位置向用户显示数据。 (the downloadable content is 20-30 MB so i want to download it to external storage if possible or else internal but either way should be private to the app) (可下载的内容为20-30 MB,因此我希望将其下载到外部存储(如果可能),或者将其下载到内部,但无论哪种方式都应为应用程序专用)

Now, I went through the google docs and it seems that data can be saved in Internal memory or External memory. 现在,我浏览了google文档,似乎可以将数据保存在内部存储器或外部存储器中。 What I don't understand is what do they mean by External memory? 我不明白外部存储器是什么意思? If I code my app for using external storage and if the user chooses to install my app in internal memory, do I have to rewrite code to fetch data from internal memory? 如果我为使用外部存储的应用编写了代码,并且用户选择将应用安装在内部存储器中,是否需要重写代码以从内部存储器中获取数据?

EDIT 1 编辑1

I got answers to that but now I have a different question. 我得到了答案,但是现在我有一个不同的问题。 If I want to put some files in the APK, I import them into Android Studio Assets folder. 如果要在APK中放入一些文件,请将其导入Android Studio Assets文件夹。 But, now I want to put some files outside the APK but package with the APK. 但是,现在我想将一些文件放到APK之外,但与APK打包在一起。 ie My file should be downloaded along with the APK to a private storage location. 即我的文件应与APK一起下载到私有存储位置。 How do I do that? 我怎么做? How do I setup Android Studio for that? 如何为此设置Android Studio?

Android have 3 major categories of memory: Android有3种主要的内存类别:

  1. System : used for OS 系统:用于OS
  2. Internal : used for app installation and app private data 内部:用于应用程序安装和应用程序私有数据
  3. External : used to store files and or may be apps (this can be a SD card) 外部:用于存储文件,也可以是应用程序(可以是SD卡)

you can chose between Internal and External to store your app data. 您可以在内部和外部之间进行选择以存储您的应用数据。

Your app will get installed on internal memory by default and user can move it on external storage. 默认情况下,您的应用将安装在内部存储器上,用户可以将其移动到外部存储上。

any of this will not affect your implementation for data storage, you need not to rewrite any code. 任何这一切都不会影响您的数据存储实现,而无需重写任何代码。

also have a look at this . 也看看这个

Update: 更新:

to answer your updated question you can keep any required file in assets and it will be bundled with your APK. 要回答您更新的问题,您可以将任何必需的文件保留在资产中,该文件将与您的APK捆绑在一起。

check this document 检查这份文件

main/assets/ 主要/资产/

This is empty. 这是空的。 You can use it to store raw asset files. 您可以使用它来存储原始资产文件。 Files that you save here are compiled into an .apk file as-is, and the original filename is preserved. 您在此处保存的文件将原样编译为.apk文件,并且保留了原始文件名。 You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager. 您可以使用与使用URI的典型文件系统相同的方式浏览此目录,并使用AssetManager将文件读取为字节流。 For example, this is a good location for textures and game data. 例如,这是纹理和游戏数据的理想位置。

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

相关问题 在Android中的外部存储和内部存储上存储文件 - Storing file on External Storage and Internal Storage in android 在Android中将文件从内部存储复制到外部存储 - Copy file from the internal to the external storage in Android Android从内部存储复制文件到外部 - Android copy file from internal storage to external Android内部外部存储 - Android Internal External Storage Android内部和外部存储 - Android Internal and External Storage Android如何将文件从内部存储移动到外部临时文件夹? - Android how to move file from internal storage to external temporary folder? 如何在Android中的文件选择器中添加内部和外部存储 - How to add Internal and External storage to File Chooser in android 将文件从应用程序内部存储器复制到android中的外部存储设备? - Copy file from application Internal memory to external storage in android? 如何在android中的内部/外部存储中保存已解析的文本文件 - How to save parsed text file in internal/external storage in android 如何从内部存储或外部存储读取文件并将文件存储在android中的arrayList中 - How to read a file from internal storage or external storage and store the file in a arrayList in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM