Android save app settings/data in Internal/External Storage

别说谁变了你拦得住时间么 提交于 2019-12-01 08:22:33

问题


I need a little help with understanding what can I do and cannot in android. I'm working on application which needs to ask user in first start to select a device (internal/external storage) where to save the data which my application is downloading over internet. So I'm trying to find answer for a few questions about this issue :

  1. Is there any limit for data in internal/external storage in Android for a single application.
  2. Can I set the directory of sqlite database which my app is using and If I can, is it a good practice or not.
  3. What should I consider when user decide to change the destination of application's data from internal to external storage. Should I create all the folders and etc. again or Android platform is doing it automatically?

Thanks in advance!


回答1:


  1. Your limit on external storage(SDCARD) is determined only by its capacity, I'm not sure about the internal storage, maybe it's the same situation.
  2. You can extend SQLiteOpenHelper and create your own DB adapter, which will manage your database and store it on SD card or /data/databases directory. I think that it's better not to place database on SDCARD, because any other app can access it there. On the other hand, /data/ folder is private.
  3. It's tricky thing. You should be careful while copying data. Check whether directory of file exist, before writing into them. It's better to explicitly create all files and directories before trying to write to them.

Here is a good example of Database Helper for accessing database. You can modify it so it can use both external and internal storage.



来源:https://stackoverflow.com/questions/8119122/android-save-app-settings-data-in-internal-external-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!