如何在android 6.0上面以编程方式清除缓存 我使用这个代码,但是它给出了方法调用错误,因为google已经弃用了Clear_app_cache权限,那么如何在android 6.0中清除缓存,这么多应用程序仍然清除缓存背后的逻辑是什么。我使用此代码
try {
Method freeStorageAndNotify = context.getPackageManager().getClass()
.getDeclaredMethod("freeStorageAndNotify", long.class, IPackageDataObserver.class);
long freeStorageSize = Long.MAX_VALUE;
freeStorageAndNotify.invoke(pm, freeStorageSize, new IPackageDataObserver.Stub() {
@Override
public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
Message msg = handler.obtainMessage(JunkFilesActivity.MSG_SYS_CACHE_CLEAN_FINISH);
msg.sendToTarget();
}
});
} catch (Exception e) {
e.printStackTrace();
}
请给我答案。其他应用程序如何清除缓存。