TIMAI2 san
I just upload your html and convert apk with MIT App Inventor (using web viewer) and
installed apk in the smart phone but there is nothing showed on the screen.
I doubt localStorage code is not working in MIT app inventor.
I have not had a chance to test this in the webviewer, but I believe you are correct. You could go out to the device's native browser (Chrome/Firefox/etc.) and try there....
An alternative may be to try something with the webviewstring, but this would only apply to your app, and not a general website, so you would need to provide options in your javascript for how the site is being used.
<!DOCTYPE html>
<html>
<body>
<p>Test Local Storage</p>
<script>
// Check browser support
if (window.localStorage){
alert('localStorage is supported');
} else {
alert('localStorage is NOT supported');
}
</script>
</body>
</html>
Thanks!
So Javascript localStorage code is not working in Webviewer .... OMG.
Maybe I need to use another way such as cache?
I just want to save username and score data into webbroswer....
OMG.....Thank you for confirmation.
Can I ask about TinyDB? I have never used it.
Can it be used from Javascript?
I mean if it has code to access from javascript, maybe I can delete localStorage code, instead I can add some other code to use TinyDB? Is it possible?
This website of yours, will it only be used by users running your app, or will it also be used by users accessing from their computer browser or mobile browser ?
You can use the webviewstring to transfer the username to the app. You will need to add some code to your javascript to set the webviewstring when the username is entered (no doubt you have a button event listener already from attempting localStorage)
You can then save the captured username in your app using tinyDB for later use, e.g. to pass the username back to the web page, also using the webviewstring.
Mmmmm,thanks.
So you mean in my javascript, if user name was input, then webviewer event becomes a trigger and it saved in TinyDB?
Do you know a specific example which I can refer to how to do it?
Here is a self contained example, using a local html file.
Click button to open web page.
Enter username.
Username is passed to the webviewstring and saved to the tinydb on pressing the Submit button
Open the web page again, and the saved username is returned to the web page
Click the Clear Username button to remove the username from the tinydb, and variables and reset the web page