0

我正在开发一个 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;
}

请建议另一种方法来删除我的网络缓存而不删除我的数据库.....

4

0 回答 0