Вопрос

My application stores web pages for offline access using a WebView.

I need to access the cached images of those pages via native code.

I first tried (unsuccessfully) reading ApplicationCache.db, but according to this answer, it's not a good idea, since the database format changes between Android versions.

I had an idea of using localStorage on my web page. Is it possible to access the stored information from native code?

Это было полезно?

Решение

On Android 4.4, you could use the WebView.evaluateJavascript API to get a result back from a javascript snippet, i.e. you could interrogate localStorage and parse the result returned. Prior to 4.4, I think using a JS bridge will be your only reasonable option. I guess you'd hook up the bridge to a StorageEvent listener in your javascript (this approach would work in 4.4, too).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top