How to delete/clear hidden data of app in android programmatically?
try this this might help but some oem have issues with this
private void clearData() {
try {
if (Build.VERSION_CODES.KITKAT <= Build.VERSION.SDK_INT) {
((ActivityManager)getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData();
} else {
Runtime.getRuntime().exec("pm clear " + getApplicationContext().getPackageName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
Clear user own apps data programmatically
Is there a simple way to do this or do I have to write code to manually reset everything the app uses.
You have to write code to manually reset everything the app uses. This should just be a matter of deleting a handful of files. Make sure your database is closed before you try deleting it.
Clear Cache in Android Application programmatically
If you are looking for delete cache of your own application then simply delete your cache directory and its all done !
public static void deleteCache(Context context) {
try {
File dir = context.getCacheDir();
deleteDir(dir);
} catch (Exception e) { e.printStackTrace();}
}
public static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
return dir.delete();
} else if(dir!= null && dir.isFile()) {
return dir.delete();
} else {
return false;
}
}
Related Topics
Apply Custom Filters to Camera Output
Creating Viewholders for Listviews with Different Item Layouts
Android SQLite: Update Statement
Android Adb Stop Application Command Like "Force-Stop" for Non Rooted Device
How to Delete SQLite Database from Android Programmatically
Broadcast Receiver Not Working After Device Reboot in Android
Cannot Install Signed APK to Device Manually, Got Error "App Not Installed"
How to Open Standard Google Map Application from My Application
How to Programmatically Clear Application Data
Add Views Below Toolbar in Coordinatorlayout
What Do Gc_For_Malloc, Gc_Explicit, and Other Gc_* Mean in Android Logcat
Custom Event Listener on Android App
Application Installation Failed in Android Studio
How to Add Multiple Widgets in the Same App
How to Create an Android Application in Android Studio That Uses the Google Maps API V2