Android 清除数据
利用反射机制清除数据:设置->应用程序->应用名->
准备条件:
IPackageDataObserver.aidl
IPackageStatsObserver.aidl
PackageStats.aidl
清除数据:
ActivityManager am = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); am.clearApplicationUserData(packageName, mClearDataObserver);
清除缓存:
Method getPackageSizeInfo = pm.getClass().getMethod("getPackageSizeInfo", String.class, IPackageStatsObserver.class); List<ApplicationInfo> application = new ArrayList(); application = pm.getInstalledApplications(0); for(int i=0;i<application.size();i++) { ApplicationInfo app = application.get(i); getPackageSizeInfo.invoke(pm, app.packageName, new IPackageStatsObserver.Stub() { @Override public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException { if(pStats.cacheSize != 0) { cacheSize += pStats.cacheSize; Log.e(TAG, "cacheSize: " + pStats.packageName + " ;" + pStats.cacheSize); } } }); }
相关推荐
85477104 2020-11-17
yangkang 2020-11-09
lbyd0 2020-11-17
sushuanglei 2020-11-12
KANSYOUKYOU 2020-11-16
wushengyong 2020-10-28
lizhengjava 2020-11-13
星月情缘 2020-11-13
huangxiaoyun00 2020-11-13
luyong0 2020-11-08
腾讯soso团队 2020-11-06
Apsaravod 2020-11-05
PeterChangyb 2020-11-05
gaobudong 2020-11-04
wwwjun 2020-11-02
gyunwh 2020-11-02
EchoYY 2020-10-31
dingyahui 2020-10-30