In android how to programmatically clear web cache without clearing database

1.6k views Asked by At

I m developing an android app in which i'm integrating facebook functionality as suggested in this blog http://www.androidhive.info/2012/03/android-facebook-connect-tutorial/ as i'm able to login first time but after logout i cannot able to login again as webcache get created in my application data.... is there any way which i can use to solve my problem ......is i have use below code as suggested here but it cannot delete delete my 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;
}

please do suggest some another way to delete my webcache without deleting my database.....

0

There are 0 answers