如何在Android中卸载我的应用程序中删除SD卡的文件夹?我的、应用程序、文件夹、如何在

2023-09-09 21:07:23 作者:大叔养的猪

我通过以下链接它说去该外部文件夹会自动我的应用程序的卸载过程中被删除。

I went through the following link which says that the external folders will be deleted automatically during uninstallation of my app.

我使用下面的code创建的文件夹和文件

I am using the following code to create the folders and file

private static String TEMP_FOLDER_PATH = Environment.getExternalStorageDirectory() + "/myAppFolder/";

我的问题是,当我卸载应用程序的文件夹myAppFolder没有被清除。

My problem is that the folder myAppFolder is not getting deleted when I uninstall the app.

请帮忙,让我知道如果我去任何地方错了...

Please help and let me know if I am going anywhere wrong...

推荐答案

将它保存在你的应用程序私人文件夹(/数据/数据​​/ yourappPackege 的)。卸载应用程序时,这个文件夹将被删除。 你可以得到你的私人文件夹的方法 getFilesDir() 其他文件无法删除,因为您的应用程序并不知道它被删除时。

Save it in your Apps Private Folder (/data/data/yourappPackege). This folder will be removed when uninstalling the App. You can get your private Folder with the Method getFilesDir() Other files can not be removed because your App does not "know" when it is being removed.