Note that there are some explanatory texts on larger screens.

plurals
  1. POClear Cache App: Why it doesn't work?
    primarykey
    data
    text
    <p>I want to click on the preference is cleared the cache of my app. I did this, but it does not work and there are errors. How can I fix?</p> <p>This is the whole source. Many Thanks!!!!!!</p> <pre><code>public class Impo extends PreferenceActivity{ Preference info; Intent intent; Preference cache; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); this.addPreferencesFromResource(R.xml.layout); info= (Preference) this.findPreference("info"); info.setOnPreferenceClickListener( new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { intent = new Intent(getBaseContext(), Info.class); startActivity(intent); return true; }}); cache = (Preference)this.findPreference("cache"); cache.setOnPreferenceClickListener(new OnPreferenceClickListener() { } } public static void clearCache(final Context context) { final File cache=context.getCacheDir(); final File appDir=new File(cache.getParent()); if(appDir.exists()) { // you might be able to change this whole code block to just "deleteDir(appDir)" final String[] children=appDir.list(); for(final String childFilePath : children) if(!childFilePath.equals("lib")) { deleteDir(new File(appDir,childFilePath)); Log.i("TAG","**************** File /data/data/APP_PACKAGE/"+childFilePath+" DELETED *******************"); } } } public static boolean deleteDir(final File dir) { if(dir==null) return true; if(dir.isDirectory()) { final String[] children=dir.list(); for(final String childFilePath : children) { final boolean success=deleteDir(new File(dir,childFilePath)); if(!success) return false; } } return dir.delete(); } } </code></pre> <p>.......................................</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload