2015-06-22 48 views

回答

0

請嘗試使用以下代碼。

PackageManager pm = getPackageManager(); 
// Get all methods on the PackageManager 
Method[] methods = pm.getClass().getDeclaredMethods(); 
for (Method m : methods) { 
    if (m.getName().equals("freeStorage")) { 
     // Found the method I want to use 
     try { 
      long desiredFreeStorage = 8 * 1024 * 1024 * 1024; // Request for 8GB of free space 
      m.invoke(pm, desiredFreeStorage , null); 
     } catch (Exception e) { 
      // Method invocation failed. Could be a permission problem 
     } 
     break; 
    } 
} 

你需要有這個在你的清單:

<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/> 

我希望它會工作的

+0

此代碼不適用於我.. –

相關問題