大佬教程收集整理的这篇文章主要介绍了在Phonegap android上清除用户数据或清除缓存,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
public static void deleteCache(Context context) { try { File dir = context.getCacheDir(); if (dir != null && dir.isDirectory()) { deleteDir(dir); } } catch (Exception E) {} } public static Boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { Boolean success = deleteDir(new File(dir,children[i])); if (!success) { return false; } } } return dir.delete(); }
所以基本上我的POSActivity.java看起来像这样.
public class PocActivity extends DroidGap { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceStatE) { super.onCreate(savedInstanceStatE); super.setrequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); super.setIntegerProperty("splashscreen",R.drawable.is); super.setIntegerProperty("loadUrlTimeoutValue",60000); deleteCache(this); super.loadUrl("file:///android_asset/www/index.html"); } public static void deleteCache(Context context) { try { File dir = context.getCacheDir(); if (dir != null && dir.isDirectory()) { deleteDir(dir); } } catch (Exception E) {} } public static Boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { Boolean success = deleteDir(new File(dir,children[i])); if (!success) { return false; } } } return dir.delete(); } }
以上是大佬教程为你收集整理的在Phonegap android上清除用户数据或清除缓存全部内容,希望文章能够帮你解决在Phonegap android上清除用户数据或清除缓存所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。