I made an application from which I make a folder and save some files in it.
What I want is, when I delete the application the folder that I make outside from application should be deleted.
I made an application from which I make a folder and save some files in it.
What I want is, when I delete the application the folder that I make outside from application should be deleted.
Add your manifest following permission
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
Then java code
File dir = getActivity().getFilesDir();
if (dir.isDirectory())
{
String[] subDir = dir.list();
for (int i = 0; i < subDir.length;i++)
{
new File(dir, subDir[i]).delete();
}
}
Follow this link to listen to when your application is being uninstalled, and in the callback, delete the folder using @sasikumar's code below. Hope this helps.