react-native-clear-app-cache
react-native-clear-app-cache copied to clipboard
Delete cache dir only
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!
@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());
}
}
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