3

I am trying to delete my offline-mode (defined in cache.manifest) files without deleting any WebSQL databases or local storage data.

I have been experimenting with deleting cache files and have used related answers on stackoverflow and elsewhere to delete the WebView cache using the answers from the following approaches:

Android Webview - Completely Clear the Cache which states to manually delete the files in Context.getCacheDir(); FWIW, I noticed the same result from using the simpler approach (which a non-accepted answer noted): WebView.clearCache(true);. This approach does delete cached-files that are not included in the cache.manifest.

I have also used the technique described in multiple other places that mention using

deleteDatabase("webview.db");
deleteDatabase("webviewCache.db");

with no impact on my offline mode files. I have verifiably deleted the webview.db, but strangely enough I have never seen a webviewCache.db file using Context.databaseList().

(As an aside, I am dubious about deleting the webview.db since I noticed a crash after deleting webview.db and trying to paste text into an input field the next time I opened my app. It seems like there needs to be some defensive programming around that trick for some apps, at least

android.database.sqlite.SQLiteException: no such table: formurl: , while compiling: SELECT _id FROM formurl WHERE (url == ?)
    at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
    at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
    at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:146)
    at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:367)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:130)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:94)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1539)
    at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1419)
    at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1375)
    at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1455)
    at android.webkit.WebViewDatabase.getFormData(WebViewDatabase.java:1150)
    at android.webkit.WebView$RequestFormData.run(WebView.java:4493)
    at java.lang.Thread.run(Thread.java:1020)

)

I also have used the "clear cache" button in the application settings page, with no effect on the offline mode files. The "clear data" button on the application settings page does delete the offline mode files, but also everything else, including my WebSQL databases and local storage keys. I also don't know how to mimic the "clear data" button programmatically, which would be useful also, though not the answer I'm looking for.

To reiterate, the point is none of these approaches is seemingly sufficient. What I want to do is delete my offline-mode cached JS/HTML/CSS and keep all of the WebSQL db files and local storage keys that have been created through the Android WebView.

I am watching my web server log so I can tell precisely when my app is requesting files or not.

Community
  • 1
  • 1
James
  • 710
  • 6
  • 19
  • This code appears to mimic the "clear data" button, at least as far as the WebView is concerned: `WebStorage webStorage = WebStorage.getInstance(); webStorage.deleteAllData(); webView.reload();` – James Apr 27 '12 at 15:30

0 Answers0