Android: Save file permanently (even after clear data / uninstall)

删除回忆录丶 提交于 2019-11-27 05:20:51

You shouldn't do that, you shouldn't force the users to keep data on their phones without their consent.

Anyway, application data directory will be deleted after uninstall, but NOT after an update

The only way to have persistent data is to use the SD card, but again, users won't like to have the data on their card after the app is uninstalled

Or you can consider:

  1. Storing the data on a remote server with some kind of authentication to retrieve it
  2. Using Data Backup service

Environment.getDataDirectory() is at least one directory where you can save files. It's on the internal storage (/data).

One case I use it is to define whether a service is running; I create a .lock file in there and always check whether it exists or not.

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