I am developing an android application that has to access the default browser local storage. The scenario is :
Is there a way to access the local storage of the browser? Also if it is possible, how to access the local storage of the other installed browser on the device?
Thanks!
It seems that there is no way to achieve this. I have tried to access browser's data using content providers but you can access only bookmarks and history.
I have also made some tests using WebView instead of browser. I tried two approaches:
You can access the local storage database like normal SQLite database. The data is stored in a single table with two columns - key and value. According to the javascript documentation writing to the local storage is a synchronous operation. This is great! The problem is that persisting the data from the browser(webview) to the file system is asynchronous. So if you write something to the local storage it is stored in the memory so it is accessible through javascript API but it is still NOT persisted to the SQLite database.
This is my personal recommendation! You have create an Android javascript interface and add it to the webview. This way you provide an API to the javascript to access your code. Be extremely careful! This could be a serious security issue! Double check your code! After that you can call your javascript methods like this webview.loadUrl("javascript://...")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With