Use this method to clear your application cache just using a function or method call 🤙
Code :
import all from io package
import java.io.*;
Clear Cache Function
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();
}
}
Then on Button click call function
clearData();
Thank you for visiting
This is my very simple and easy solution for clearing your cache from the app hope it's helpful for your Android project if you have any questions contact us on ettech1840@gmail.com
Post a Comment
Post a Comment