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

前端 未结 2 630
谎友^
谎友^ 2020-11-30 11:46

I would like to know if there is a way to store a small amount of data permanently.
By permanently I mean I want the data to persist even if user clears app data / unins

相关标签:
2条回答
  • 2020-11-30 12:13

    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
    0 讨论(0)
  • 2020-11-30 12:32

    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.

    0 讨论(0)
提交回复
热议问题