Android - 在卸载时保留或删除应用程序创建的文件 [英] Android - Preserve or delete files created by the application on uninstall
问题描述
我创建了一个应用程序,用于创建文件并将其存储到 SD 卡.有没有办法将文件夹与应用程序绑定,以便在用户在 android 设备上运行卸载时删除所有文件?
I created an application which creates and stores files to sdcard. Is there a way to bind the folder with application in order to delete all files when the user runs uninstall on android device?
推荐答案
您的应用程序无法知道它正在被卸载(不修改内核).卸载应用程序时,会自动删除 data/data/your.app.package
中创建的所有文件.
There's no way for your application to know that it is being uninstalled (without modifying the kernel). All files created in the data/data/your.app.package
is deleted automatically upon application uninstall.
我认为没有从 SD 卡中清除任何内容.您可以进行快速测试并找出答案.
I don't think anything is cleared from the sdcard. You can do a quick test and find that out.
另一种方法可能是让另一个应用程序检查是否安装了此应用程序.如果没有,它可以完成清理工作.
Another approach could be to have another application that checks whether this application is installed or not. If not, it can do the clean-up work.
这篇关于Android - 在卸载时保留或删除应用程序创建的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!