Android: Delete app associated files from external storage on Uninstall?

后端 未结 4 953
情话喂你
情话喂你 2021-01-02 08:15

It\'d be convenient if an application I\'m writing stored some files to external storage permanently (so they persist after the application has been exited[destroyed]), but

4条回答
  •  难免孤独
    2021-01-02 08:37

    Yes, this is possible. Simply write your files to the external files directory:

    File dir = getExternalFilesDir(null);
    

    This will create a folder at /Android/data/your.package/. Note that this is not External as in sdcard, but it is publicly accessible. If a user uninstalls your app, this directory will also be removed, along with all of its contents.

提交回复
热议问题