How can jQueryMobile app use IndexedDB database? - android

I want to build jQueryMobile app using IndexedDB technology for databases. While developing in web browser the app is working. How can I convert this app into native android app (using phonegap) and to keep the data from IndexedDB database?
I know that location of my IndexedDB database is at:
C:\Users\<User Name>\AppData\Local\Google\Chrome\User Data\Default\IndexedDB\
So is there a way for my app to use IndexedDB at the mobile devices ?
For conversion I'am using phonegap cloud but the converted app does not have access to the database. I'am testing with Nexus 7 tablet. The app on my PC works great.
EDIT 1:
I'am testing with Google Nexus 7 tablet. Android version is 4.4.2 so i suppose that IndexedDB is supported on my device. The problem is that I don't have idea how to implement the file from the location above (what to do with it) while conversion, so that the database would be found on my device. (I'am using phonegap cloud for conversion).

unfortunatly IndexedDB is not supported by android browser before version 4.4.
Check this page for availability : http://caniuse.com/indexeddb
There seems to be a way, look at Iwona TrÄ…bka's answer on this page.
Or you can use something like Lawnchair to encapsulate database access.

Please go through this link for the support, INDEXDB SUPPORT
I had tested it on android 4.3 and it did not worked but here it shows it has support on 4.4.
Also, please go through this blog for IOS

On Android 4.x an older version is implemented but on Android 4.4 it should work without plugins. I use a polyfill for iOS and Android which actually uses websql. The polyfill adds the indexedDB API while I isn't actually supported and converts the calls to websql!
websql is supported on android 2+. See the indexedDBShim for details: https://github.com/axemclion/IndexedDBShim/
Note: The polyfill isn't perfect, not all methods support an IDDBKeyRange but you can workaround it in most cases. It does workvon iOS 4+ if you want to support iOS in the future.
Edit: Also the answer your question, you can just open the database by name. There is no need to know the actual location on disk.

Related

CSS and Javascript features available in Cordova/Ionic/PhoneGap apps?

When writing CSS and JS for Cordova apps, how do I figure out which features are available to use? When I go to caniuse.com, am I looking at iOS Safari and Android Browser or Chrome? Is there a table somewhere that will help me map Cordova versions, OS versions, and browser versions?
I've been stung once by the JS await operator not working in an app that I thought would work in iOS 10.1. I'm now not sure how to tell what's the oldest Android version on which that app will work. And I'd like to be able to figure out which features are usable based on an OS decision predetermined by my clients or managers.
This is a very good question and one that cannot be answered with a single sentence. I can share some experience though:
Android vs. IOS
IOS is the most predictable as all Apps have to use the same WebView that comes with the OS. When you set a minimum IOS version (for example 10.0) you can look up supported features for Mobile Safari on caniuse.com.
Android is a completely different story as there is absolutely no way to predict which WebView the user is using. It will usually be some version of Chromium but starting from Android 5 it can be updated independent from the OS via the Play store. If you absolutely must support Android 4 you could create a separate build and using Crosswalk (unmaintained but still working) to get a predictable WebView.
JavaScript / CSS
If you're using Ionic then JS will usually be less of a headache as you develop in TypeScript and transpile to ES5. For CSS on the other hand you will have to resort to the usual browser checks / hacks / fallbacks as we did back in the days when we had to deal with browsers like IE6.

Do 'Chrome Apps for Mobile' use native web-view on each platform?

Is Chrome Apps For Mobile only a collection of Apache Cordova plugins for each mobile platform or does it intend to also replace the native web-view with Chrome based web-view ?
This question and this slide on Google Docs seem to indicate that it is only a collection of plugins. This question says that on iOS it uses the native web-view.
What about on Android and any future platforms Google might support?
Yes, all current Chrome Apps for Mobile using the cca toolkit are cordova based and thus use the Native system WebView.
On iOS, this currently seems unlikely to change because of policy restrictions (but hey, who knows).
On Android, the cordova contributors would like to experiment with supporting the use of custom web renderer implementations. This is being discussed as a possible cordova-4.0 major version bump milestone feature, and would thus target fall/winter of 2014. This is really just a dream at this point, but its certainly a feature that is on everyones mind.
I should note, there are a many downsides to doing this, its not all gravy. Using a custom WebView means adding ~20meg to application download size, and means significantly more memory/video memory usage on device. Alternatively, we could ask users to download a separate "cordova-runtime" app from the store (like Adobe Air for Android, or like you have to download a Java Runtime for desktop), but users usually dislike that experience.
Also, with Android 4.4 KitKat now having a chrome-based WebView, which enabled remote debugging and implements many modern web capabilities, the usefulness of a custom WebView is shrinking.
Finally, there is already a project that does what you ask, but isn't cordova based, and is not used by the cca tool: Intel's Crosswalk Project. Just adding it for reference. Their wiki goes over a lot of tradeoffs with their approach.

Execute Android phonegap app with opera/Chrome mobile

I have developed an android webapp with Phonegap (Cordova 2.7.0). The app needs to receive some prices pushed by a server through the use of a third party JS API (Diffusion).
The app works well on standard desktop browsers, where websockets are available, however on the Android emulator does not seem to work due to this latter's lack of support for websockets.
I thus thought to use a different mobile browser, such as Opera or Chrome, however I now have the problem of ensuring Android uses this new browser, when executing my webapp, rather then the standard one.
Does anyone know how to do this?
Thanks.
PhoneGap for Android uses WebView, not a browser.
The simplest solution is to use a Web sockets plugin for PhoneGap, or to write your own such plugin if you cannot find an existing one that you like.
It is theoretically possible to rewrite PhoneGap to use the Android version of Chromium, but this will be a massive undertaking.

phonegap - sqlite or Indexed DB?

I am web developer starting with phonegap. I need to create one app for iPhone, android and Windows Phone 8.
I need to store some data (too big for localStorage) locally.
I don't know witch solution is the best:
Phonegap provides Storage (based on WebSQL - which is deprecated), but it is not supported by windows phone. Is there any plugin to fill this gap?
I read about Indexed DB, but I haven't used it before and it is not very intuitive for me. I am not sure if it is fully supported in all platforms? I based on (http://blog.nparashuram.com/2012/10/indexeddb-example-on-cordova-phonegap_12.html)
Or maybe I can use phonegap plugins https://github.com/marcucio/Cordova-WP-SqlitePlugin for windows phone and https://github.com/marcucio/Cordova-SQLitePlugin for android and iphone.. Then my code would be the same in all platforms as I suppose.
Did someone create such an app before? I would be greatful for any solutions or ideas.
Cordova WP8 supports IndexedDB only. iOS and Android WebSql only. Since WebSql is deprecated (I know how many people love/use it and agree that in many situations WebSql is very cool) I would recommend to proceed with IndexedDb and use the following polyfill for Android/iOS.
PhoneGap polyfill for IndexedDB that makes the IndexedDB API to work with WebSQL
Example
Latest Update (May 05, 2014):
New Cross Platform Cordova WebSQL plugin by MS Open Tech
Microsoft Open Technologies is publishing the new open source WebSQL plugin for Apache Cordova and PhoneGap. This plugin allows developers to integrate a persistent SQL-based local storage solution in their Cordova apps using the exact same JavaScript code across Android, iOS, Windows Phone and Windows Store.
IndexedDB -
It is incompatible with many types of popular mobile OS and versions
It is only compatible with very specific versions of mobile OS
Developers cannot use SQL with IndexedDB. SQL statements can be used on SQLite and WebSQL
Most developers actively avoid using IndexedDB as much as they can
WebSQL -
It has been deprecated by W3C which means it is no longer maintained or developed
It requires another plugin to enable mobile applications to work with popular mobile OS such as Google Android and Apple iOS
SQLite -
It received an award from Google
SQLite has its official website. IndexedDB and WebSQL do not
On Google, SQLite returns 1.8 million results. WebSQL returns a bit less than 700K results and IndexedDB returns 282K results.
Developer can use common SQL statements with SQLite
It is compatible with most versions of all popoular mobile OS such as iOS and Android
If you want a quick tutorial on SQLite
Storage of SQLite database using Android and Phonegap
LocalForage seems to be the best and newest solution:
https://github.com/localForage/localForage (1000 commits, 83 contributors)
It has fallbacks for none supported navigators.
I haven't tried it yet (over phonegap) but as soon I do i'll give you feedback ;)
How about using my open source library, ydn-db? It has very nice abstraction layer on top of those.
Edit:
Android todo app: https://bitbucket.org/ytkyaw/android-todo/wiki/Home
YDN-DB project repo: https://bitbucket.org/ytkyaw/ydn-db/wiki/Home
API doc: http://dev.yathit.com/api-reference/ydn-db/storage.html

Offline Web Application HTML5 on Android

I want to develop a HTML5 Web App.
I read that in HTML5, you can use the new feature "Offline Web Applications"
With the *.manifest file
I read an article from november 2010, that this feature only works on the iOS platform.
Does it work on Android now?
Yes. It works on Android as well as iOS and most desktop browsers. You don't need PhoneGap unless you want to access native features or deploy to the App store.
UPDATE:
Check out this chapter from Jonathan Stark's book: Building Android Apps with HTML, CSS, and JavaScript.
In general, http://mobilehtml5.org/ provides nice mobile compatibility tables to answer this and other similar questions.
Yes it can. Here's an example for an offline game:
http://www.davidgranado.com/2010/11/make-a-set-mobile/
The one thing that sucks is that iOS generates a nice icon automatically. However, android doesn't. Also, I noticed that on random versions of android, it will display an error popup about the fact that it can't connect to the internet, but still runs fine after that.

Categories

Resources