hello friends
welcome to the CodersArt blog.
Today we are going to learn how to clear data in android using java. when we are using android application we can see the data or data cache some of the reason app hang because of cache data. using below method we can remove the cache in android.
welcome to the CodersArt blog.
Today we are going to learn how to clear data in android using java. when we are using android application we can see the data or data cache some of the reason app hang because of cache data. using below method we can remove the cache in android.
private void clearAppData() { try { if (Build.VERSION_CODES.KITKAT <= Build.VERSION.SDK_INT) { ((ActivityManager) getSystemService(ACTIVITY_SERVICE)).clearWatchHeapLimit(); } else { String name = getApplicationContext().getPackageName(); Runtime runtime = Runtime.getRuntime(); runtime.exec("pm clear " + name ); Log.w("clearAppData------", "clearAppData"); } } catch (Exception e) { e.printStackTrace(); Log.w("clearAppData------", "clearAppData exception"); } }
Comments
Post a Comment