Issue
In Android's WebView, what's the difference between DomStorage, Database and AppCache?
I'm confused about these three settings. Now I need a instance of WebView that I can use localStorage in JavaScript.
Here is an example:
if (localStorage['avatar_user_' + nick]) {
obj.src = localStorage['avatar_user_' + nick];
} else {
var url = avatar_path + nick + '/avatar.jpg';
new Oauth().img("jpeg", url,
function(data) {
if (data != '') {
obj.src = data;
localStorage['avatar_user_' + nick] = data;
}
}, function() {}
);
}
In the above code I really get the image from the web, and it will be loaded from the localStorage the next time I need it, but the storage only lasts as long as the app's lifetime.
If I restart my app, then the image will be loaded from the web again.
I setup my WebView as follows:
mWebSettings.setAppCacheEnabled(true);
mWebSettings.setDomStorageEnabled(true);
mWebSettings.setDatabaseEnabled(true);
mWebSettings.setDatabasePath("file:///data/data/com.xxx/databases");
but I can see the files in file:///data/data/com.xxx/databases remain unchanged when I'm adding something into localStorage.
So my question is how to make my webpages store data and keep them after the app is closed?
And does it matters if I use multiple WebView in a app and point the DatabasePath to the same folder?
And if you can tell me the difference between DomStorage, Database and AppCache it would be so much better!
Solution
I'm not hundert percent sure, but DomStorage seems like an synonym for WebStorage. This is a technique to store data on client site as key=value pairs.
http://diveintohtml5.info/storage.html
Database means that the client-side SQL database will be enabled.
http://www.html5rocks.com/en/tutorials/webdatabase/todo/
And AppCache is a technique to make whole websites available for offline usage.
http://appcachefacts.info/
Answered By - Marvin Emil Brach
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.