7 Replies Latest reply on Apr 5, 2013 10:49 PM by John Michael Vincent Rustia

    native apps: localStoraging

    Luca Priano

      Hi,

       

      I'm wondering if it's possible using html5 localSorage to storage data in a native app or if the only right way is using Rhom. I've made a test using html5 localStorage in a native app and all work fine, but if I turn off the device, when then I turn it on...the data are lost

       

      is it wrong using localStorage in native apps?

       

      Thanks in advance

        • Re: native apps: localStoraging
          Luca Priano

          Also using Web SQL database there is the same problem...if I restart the device the data aren't preserved. I've a native app which load an html page with WebView.navigate, and I store data in this html page . If I close the app and then restart it...no problem to get stored data (both using localStorage and Web SQL DB), but if I restart the device, I lose all stored data . I'm using an Android.

           

          Should I include a Config.xml to my app with some capabilities to preserve data?  Or the only right way is to use Rhom?

           

          Thanks a lot for any hint

            • Re: native apps: localStoraging
              Andraž Stošić

              Luca Hi,

               

              I don't recommend using WebSql since it's specification is depreciated and no further maintenance is planned http://www.w3.org/TR/webdatabase/. Is there any special reason why aren't you using Rhom?

               

              Now answer to your question is Rhom the only right way? Well it's not the only way but it's quite strong and abstract so you can quickly add persistence data into your application. It can be quite fast when dealing with large sets of data when used properly. And the last thing is that you can use it with RhoConnect with little programming skills involved to sync with back end data. So my advice is to go with Rhom when building native apps.

              1 of 1 people found this helpful
                • Re: native apps: localStoraging
                  Luca Priano

                  Thanks Andraz,

                   

                  well my will to use html5 localStorage is due to the fact that I've a web app deployed onto a web service and I access to it by my native app installed onto device using WebView. The app on web service already use localStorage to store data (a small amount of data), so I would have like to re-use it also when I access to it by my native app.

                   

                  Anyway the strange behaviour is only when I restart device...the data stored are lost, if I turn off and then on the app, no problem!

                   

                  I make some investigation yet, then I'll consider using Rhom!

                   

                  Bye

                    • Re: native apps: localStoraging

                      Oh it seems you still want to use your existing web application on the server side in your native rhomobile application, your approach is in Rhomobile's term is Rhoelement-enabled Web App or Hybrid Approach, you could actually just use rhoelements runtime application (http://docs.rhomobile.com/rhoelements/rhoelements2-webapps) instead of directly creating a new native app.

                       

                      The issue with RHOM in this setup is you wont be able to use it, since its API is only working in Ruby Level, and none in Javascript level/HTML meta tags level. So the only hope you could have is to get the local storage of HTML5 working to leverage your existing web application.

                       

                      But another choice for you is to migrate your web pages into internal ERB views in your rhomobile application and use the

                      Native Application Approach which will allow you to utilize Rhom.

                       

                      But the second approach is of course not that fun, but it will give you additional access to device capabilities. I hope they could reall yfix the local storage API in rhomobile since it exist to do such job. Currently I did also encounter your situation but the benefit of the device capabilities push us to take the Native Application Approach, anyway you are creating a native application, why not take full advantage of its API, cause if not, existing browser would be better than your native app.

                      • Re: native apps: localStoraging
                        Pietro Francesco Maggi

                        Luca, which device are you using?

                         

                        LocalStorage and WebSQL are available in RhoElements for Native, Hybrid applications and Web Applications.

                         

                        What I can suggest is to build a small native application that just check for the availability of the connection and then "navigate" to your remote webpage, as an alternative you can simply modify the start_path parameter in the rhoconfig.txt to your remote URL. This allows you to have a custom setup package (even for iOS) with your own icon.

                         

                        Pietro

                          • Re: native apps: localStoraging
                            Luca Priano

                            @John

                            I would like to use RhoElements but some device capabilities aren't available, hence my decision to make a native app...waiting for next RhoMobile release which seems to be promising!

                             

                            @Pietro

                            Well I'm using these three devices: Samsung Galaxy S3 - Samsung Galaxy S Advance (both Android) and a PIDION HM40 (Windows Mobile 6.5): using RhoElements, localStorage works great, but if I try to use a native app, everytime I restart device I lose stored data . Is there any different about browser used between RhoElements and a native app? Did you ever succesfuly use localSorage in a native app?

                             

                            What would you suggest to use to understand online/offline status in a web app? I seem html5 navigator.online isn't very reliable!

                             

                            Thanks a lot