Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete cache dir only #5

Open
joaopiopedreira opened this issue Feb 3, 2019 · 2 comments
Open

Delete cache dir only #5

joaopiopedreira opened this issue Feb 3, 2019 · 2 comments

Comments

@joaopiopedreira
Copy link

Hi and thank you for this package. I wonder if you could add an option to clear only the cache directory (and not the documents directory). Thank you!

@KPS250
Copy link

KPS250 commented Feb 10, 2019

@joaopiopedreira I looked into library and it deletes files and cache directory contents. I just skipped file file directory content deletion by commenting the below line from the ClearCacheModule.java:

public void clearCache() {

        getReactApplicationContext().deleteDatabase("webview.db");
        getReactApplicationContext().deleteDatabase("webview.db-shm");
        getReactApplicationContext().deleteDatabase("webview.db-wal");
        getReactApplicationContext().deleteDatabase("webviewCache.db");
        getReactApplicationContext().deleteDatabase("webviewCache.db-shm");
        getReactApplicationContext().deleteDatabase("webviewCache.db-wal");
        //清除数据缓存
       // clearCacheFolder(getReactApplicationContext().getFilesDir(), System.currentTimeMillis()); // Comment this line to skip file content deletion
        clearCacheFolder(getReactApplicationContext().getCacheDir(), System.currentTimeMillis());
        //2.2版本才有将应用缓存转移到sd卡的功能
        if (isMethodsCompat(android.os.Build.VERSION_CODES.FROYO)) {
            clearCacheFolder(getExternalCacheDir(getReactApplicationContext()), System.currentTimeMillis());
        }

    }

@joaopiopedreira
Copy link
Author

joaopiopedreira commented Sep 21, 2019

Hi @KPS250, sorry for my late reply, only saw this now. Thank you for your comment above, very helpful. Would you point me in the right direction for iOS too? Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants