在android中如何以编程方式清除Web缓存而不清除数据库

时间:2012-08-14 12:18:42

标签: android caching application-data

我正在开发一个Android应用程序,其中我按照此博客中的建议集成了Facebook功能http://www.androidhive.info/2012/03/android-facebook-connect-tutorial/ 因为我能够第一次登录但登出后我无法再次登录,因为在我的应用程序数据中创建了webcache .... 有没有什么方法可以用来解决我的问题......是我使用下面的代码,如这里建议但它不能删除删除我的摄像头......

static int clearCacheFolder(final File dir, final int numDays) {

    int deletedFiles = 0;
    if (dir != null && dir.isDirectory()) {
        try {
            for (File child : dir.listFiles()) {

                // first delete subdirectories recursively
                if (child.isDirectory()) {
                    deletedFiles += clearCacheFolder(child, numDays);
                }

                // then delete the files and subdirectories in this dir
                // only empty directories can be deleted, so subdirs have
                // been done first
                if (child.lastModified() < new Date().getTime() - numDays
                        * DateUtils.DAY_IN_MILLIS) {
                    if (child.delete()) {
                        deletedFiles++;
                    }
                }
            }
        } catch (Exception e) {
            Log.e("error Tag",
                    String.format("Failed to clean the cache, error %s",
                            e.getMessage()));
        }

    }
    return deletedFiles;
}

请不要删除我的数据库,建议另一种删除我的网络摄像头的方法.....

0 个答案:

没有答案