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

后端 未结 4 967
情话喂你
情话喂你 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:49

    Quoting from the blog post of CommonsWare

    • Internal storage: your file is deleted

    • External storage: if you wrote your file to a location rooted at getExternalFilesDir() or getExternalCacheDir(), your file is deleted. If you wrote your file elsewhere (e.g., Environment.getExternalStoragePublicDirectory()), your file is not deleted

    • Removable storage, prior to Android 4.4: removable storage is not officially accessible; if your file winds up out there, it should not be deleted when your app is uninstalled

    • Removable storage, Android 4.4+: AFAIK, if you write to a supported location (getExternalFilesDirs() or getExternalCacheDirs()), your file is deleted if that particular bit of removable storage is in the device at the time of uninstall

提交回复
热议问题