What to Use for PhoneGap Database Storage - html

I am writing an application using PhoneGap, and am finding it hard to work out how to store my data in a database. For the minute I just want to keep an open mind as I will be recommending technology options to our company.
The PhoneGap API for storage is here,
http://docs.phonegap.com/en/1.3.0/phonegap_storage_storage.md.html#Storage
It is based on this HTML5 spec,
http://www.w3.org/TR/webdatabase/
The problem for me is that the specification for this is not being maintained any more, and the standard has been deprecated.
The other problem is that I implemented a database using web database, and the versioning didn't work properly.
What is PhoneGaps stance on this and will PhoneGap look at other technologies such as the Indexed Database API,
http://www.w3.org/TR/IndexedDB/#database-concept
I am storing JSON data in the localStorage for now which is working great, but I am wondering if my database could get too big and it might not be the best option.

I faced the similar issue while developing an application few months back in which we were expecting to port the application to different platforms (with different versions). So instead of using the core storage mechanism which phonegap offers we went on using a dedicated storage framework which can provide consistent api but uses the best underlying storage mechanism.
There are variety of JS frameworks which can help you use the underlying storage. The following are few might interest you if you are planning to use the app on different platforms.
PersistenceJS - persistencejs.org
lawnchair - http://westcoastlogic.com/lawnchair/
persistencejs uses gears and localstorage in combination which helps to run the app on BlackBerry 5.x devices as well without any change.
I went on using the persistencejs and it have really worked well till now. We have ported the application on Android, iPhone, iPad, BlackBerry (5.x and greater)

Related

Should i use Lawnchair or localForage to maintain data offline

I'm writing an app using Ionic framework. I use mongodb as a datastore in the cloud but the lists are too comprehensive and is slowing the app down. After consuming millions of hours reading about client side storage I still dont have a clear answer.
I hoped it would be possible to serve these comprehensive json files native from the client, which is ios + android + windows phone but having not "server" to serve it that idea seemed to be a dud. Dont know if my limited understanding of the rest API in angular is at fault but logically that idea doesn't make sense.
Looking at on native sql clietn I investigated sqlite. Since sqlite implementation on these different platforms(ios + android + windows phone) will be a pain i looked at the different types of browser caching.
I dont want to go into to much detail but localstorage is to simple for my structures, and the other options are not being supported or deprecated. Its a mess. However, the two options regarding offline data solution i have found is Lawnchair and localForage.
What is the differences between these two as they provide the most comprehensive solution based on the client. Any one willing to suggest a beter / worse option.
Then there is the site files which i also want to cache using app cache but I'm not sure how to since I'm using https://www.npmjs.org/package/generator-ionic which is kick-ass by the way.
Lawnchair syntax is a bit more complicated than localForage and the project is no longer updated whereas localForage is (and it's developped by mozilla).
If you are using angular, then go with https://github.com/ocombe/angular-localForage which is my implementation of localForage for Angular, it will be really easy and you can force the driver you want to use if necessary (but on mobile local storage will never be choosen since all mobile smartphones support either websql or indexeddb).

HTML5, jquery mobile app deployed as stand alone app

I have read a few forums and articles on this but can't get a clear answer.
I need to build a mobile app that can run on any platform/device. It looks like HTML5 + jquery is the best option but I need the application to do the following:
The app must run on any platform (Windows Phone, iOS, Android, etc).
It must work as a stand alone application. Meaning it must work without internet connection.
Because it is stand alone, I need a local database on the device. The database can be embedded in the app. I'm thinking SQL CE.
The local database on the device must be able to sync to a SQL Server database.
The app needs to interact with features of the device like the camera, or GPS device.
Is it possible to build such a mobile application?
I am using ASP.net MVC 4 to do the development.
If you want to use HTML5 and JQuery then the PhoneGap/Cordova framework would suit you best.
Phonegap is a cross platform framework that gives you access to the device features like GPS and Camera using a standard javascript API.
The app must run on any platform (Windows Phone, iOS, Android, etc).
Phonegap is compatible with all these and many more including blackberry. See here for full list: http://phonegap.com/about/feature/
It must work as a stand alone application. Meaning it must work without internet connection.
PhoneGap runs as a native application inside each devices webview. It does not need access to a data connection to run
Because it is stand alone, I need a local database on the device. The database can be embedded in the app. I'm thinking SQL CE.
PhoneGap cannot run its own SQL Database like a standard native application but it can use the web standards Web Storage and Web SQL. Though this approach does have limitations. Read more about this here: http://docs.phonegap.com/en/1.2.0/phonegap_storage_storage.md.html#Storage
The local database on the device must be able to sync to a SQL Server database.
This would be upto you to design and implement but can definitely be done
The app needs to interact with features of the device like the camera, or GPS device.
Most device features supported with PhoneGap. See above link for full support list.
If the lack of a full SQL Database support is a problem for you there are frameworks like Titanium Appcelerator that build a fully native cross platform app for you that may be more suited to your situation.
http://www.appcelerator.com/platform/titanium-platform/
But if you're using HTML and JQuery to go cross platform then PhoneGap is your best bet.
Edit: Also there are plugins for PhoneGap to run a standard SQLite DB but this requires extra work on each platform. Every platform you develop for would require a compatible plugin.
http://brodyspark.blogspot.com.au/2012/12/cordovaphonegap-sqlite-plugins-offer.html
Use PhoneGap: http://phonegap.com/
or Apache Cordova: http://cordova.apache.org/
or Intel XDK: http://xdk-software.intel.com/

Is there any JavaScript framework that supports offline scenario in MVC 4 SPA?

Steve Sanderson presented MVC 4 SPA "Delivery Trucker" for mobile devices with offline support using upshot.js JavaScript framework.
http://channel9.msdn.com/Events/TechDays/TechDays-2012-Belgium/199
It seems that the MVC team dropped support for upshot.js
Is there any other JavaScript framework to provide offline support for mobile devices?
Example: MVC4 SPAs application is running on a smart phone. The phone might lose reception. SPA is using the HTML5 local storage to save data changes when offline. The JavaScript framework in question will detect when the mobile device is back online and synchronize the changes from the HTML5 local storage to the DB Server.
It would be really helpful if the MVC team provides support for Single Page Applications (SPAs) templates running on mobile devices offline.
Please vote for it if you think it will be helpful:
http://aspnet.uservoice.com/forums/147203-spa-single-page-application-framework-with-javas/suggestions/3721721-offline-support-for-single-page-application-templa
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
SpineJS has support for persistent local storage of model objects. Here's the guide. It's actually surprisingly transparent for the programmer to use and I highly recommend it.
Specifically, it fits your requirements in the following way:
it enables you to save state changes locally when offline
it's possible to announce itself to a server-side service when it's back online and push changes to the backend
the creators of Spine.js plan to implement an automation of that process using AJAX CRUD replays of the transactions you did when offline, read about it here.

Installing an offline html app and data onto an iPad

I am contemplating buying an iPad and am wondering what options I will have for developing an app for personal use ... specifically whether I will be able to do it as an offline browser app. The app currently exists as an Android Java app; it interacts with a large local database (about 3MB) and displays images and text drawn from a very large pool of resources stored locally (about 2GB).
My immediate questions are:
How would I get the files (html/javascript, database, images and text) transferred into the iPad's storage from a Windows PC? With Android this is a simple matter of hooking up via USB and using Windows Explorer. Googling suggests that for an iPad I might have to use an app on Windows called DiskAid, but this costs $25 which seems a bit steep for my simple purpose. Are there free alternatives?
Once the files are installed on the iPad how would I run the html app? On Android this appears to be a matter of keying "file:///sdcard/MyBrowserAppFolder/mybrowserapp.htm" into the browser's address box. Does th iPad browser work in a similar way.
There are two basic kinds of applications that run on iOS.
Mobile designed web applications that are hosted on a server and accessed through Safari or another browser.
Native applications built using Xcode and usually objective-c.
For the latter, you could use the phonegap framework to build an app using existing html and javascript.
My personal advice is to invest the time to learning how to code this up using objective-c. Depending on what format your db is in, importing the structure and data might be trivial. It will take an investment of time, but doing things using the native tools is the best choice for iOS development in my opinion. I was in the same situation (PHP, VB.NET and Javascript developer) and just decided to take the time and learn to do it right. This was a great decision and the development time of a simple to moderate application takes very little time now.
Safari on iOS does not support the URL's of type file:// natively. So you either write your own app, purchase an app or use something like a local web server after jailbreaking.
Alternatively, and if you can verify that the app you have mentioned does what you want to do, then maybe $25 is not so much of a price. Depends on what your time is worth :)
However there are cheaper apps around that allow to transfer and read html via wifi and usb. (Not sure I can name them here)
The USB transfer aka iTunes Filesharing is a standard function that a developer can enable in the info.plist of their app. Many apps use this to transfer data between Computer and iDevice.

How to use persistenceJS in phonegap application?

We are building a field data collection tool that will be available in two versions:
Fully html5 -- directly
downloadable through your browser
(does not support camera access,
etc..).
Hybrid using phonegap --
installation required (does support
camera access, etc..).
In the html5 version we are using
persistenceJS to store data. Somehow this does not seem to work in the hybrid version and it would be nice to keep the code base as generic as possible.
Does anyone know about using persistenceJS in combination with phonegap?
Note 2011/04/04: In a prototype we have gotten persistenceJS to work in phoneGap. Probably some kind of library is interfering in some way.
Phonegap is kind to persistencejs.
The only potential trouble is with iOS, which made its websql storage non-persitent starting in iOS 5. In other words your database can be periodically removed by the operating system.
If you upgrade to Phonegap 1.6 and up, there is a built-in fix for this problem and your persistencejs will work just fine.