Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 1638

almosturban
Aspiring developer
Profile
Posts: 19
Reg: May 23, 2011
Canada
1,840
07/26/14 03:09 PM (9 years ago)

Local Storage for Androd apps

Hi All, I am having some trouble utilizing local storage on an Android application. I am using the code from the Thomas Hardy example: http://www.thomashardy.me.uk/using-html5-localstorage-on-a-form My code works just fine in a web browser on my PC but when I link to the webpage in my Buzztouch Android app the data is not saved in local storage. Basically the code it working, as soon as its in my Android app its not working anymore. Do I need to make any changes in Eclipse to enable Local Storage? Will local storage even work for Buzztouch apps? Any help/advice is appreciated. Thank you,
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
07/26/14 03:44 PM (9 years ago)
Im not sure but I think because webview is just a web viewer and not a browser,so it couldnt use it.Im not sure if when you set the control panel options for the custom url to cache the data, if not maybe that will work. I could see it working with browser apps but not webview but im no expert either. You could maybe use the login screen with Chris1's form plugin
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/26/14 08:09 PM (9 years ago)
If it works in Android, it works in Buzztouch. BT does nothing other than 'lay out' the basic stuff for you already. Nothing is in there to 'stop' you from doing anything. Try it in the browser on your android device (or perhaps even the android emulator, although that may not be the best test scenario). If it works in your android browser, then it'll work in your buzztouch project. You just might need to tweak it a little more. Cheers! -- Smug
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
07/27/14 12:39 PM (9 years ago)
I juat thought about what I was saying.you need a webview to make a web browser lol
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/27/14 01:16 PM (9 years ago)
It is do-able in a webview, there is something you need to configure in the Android project settings to enable local storage - it is not enabled by default. I have done this myself, with a form, but I cannot remember what I did, but I have it documented somewhere. I could probably find it tomorrow if the following doesn't help. A quick google showed this http://stackoverflow.com/questions/5899087/android-webview-localstorage http://stackoverflow.com/questions/17615526/android-webview-localstorage
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
07/27/14 01:31 PM (9 years ago)
Ignoring StackOverflow, I found three sources of information on this topic, let us know what works for you. -- Niraj #1 - http://www.nurne.com/2013/05/android-how-to-enable-html5.html webView.getSettings().setJavaScriptEnabled(true); // enable javascript // enable local storage webView.getSettings().setDatabaseEnabled(true); webView.getSettings().setDatabasePath("/data/data/" + getPackageName() + "/databases"); webView.getSettings().setDomStorageEnabled(true); #2 - http://mytechead.wordpress.com/2012/03/14/enable-html5-localstorage-in-webview/ By default android WebView doesn’t allows us to use the HTML5 local storage feature. So if any of you are trying to create a WebView and want to use HTML5 localstorage feature as well then you have to explicitly enable the DOM STORAGE using the following code : WebView mWebview = (WebView) findViewById(R.id.my_webview); .... .... .... mWebView.getSettings().setDomStorageEnabled(true); this ensures that HTML5 local storage works in your WebView. #3 - https://github.com/didimoo/AndroidLocalStorage LocalStorage is partially broken in Android webviews : Local storage is supposed to be a persistent storage available accros all tabs (or windows) of a browser. On Android, LocalStorage works well but only in the current webview. Multiple webviews of the same app can't share the same data with LocalStorage. That is sad ! JavaScriptInterface to the rescue !
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.