Local DB using cordova in 2020 [Android/IOS] - android

I need to store objects and arrays in my cordova mobile app.
I need both android and ios support.
WebSQL seemed pretty good, but now it's not supported since september 2019 (version 13) on IOS, and I don't want to have different technology for android and ios.
IndexedDB is looking good, and is supported according to caniuse.com, but on the cordova docs, it's said it's not supported by IOS.
Cordova docs seems pretty old.
I work with Cordova and AngularJS, and I need to sync from time to time the local DB to Firebase.
Maybe someone can share his experience about local storage here.
Thank you for your answers.

You can store values in the RAM within an Object dynamically, you can store it with sqlite like this:
https://www.npmjs.com/package/cordova-sqlite-storage
or you can store values in a file.
I give you a hint. You should do Android apps with java and IOS apps with swift. These are
natively supported programming languages.

Related

Why to use Phonegap if you only develop on one platform

I've been checking out a lot of open source projects for a SQLite map database I'm getting ready to develop and have seen a lot of finished Phonegap applications that are just primarily written natively for one platform with an index that just have references. Why do I see this so much? What the advantage to this?
If you don't know the language+the sdk&apis you need to know to build native apps
If you think maybe oneday you will have to target an other platform
if you want to use some libraries available in javascript
if you want to share code between your app and a webapp
Ok, there are also many disvantage as speed or the need to test with many devices because you rely on the webview. If the target is android maybe using crosswalk can remove many of the disadvantages.

How can jQueryMobile app use IndexedDB database?

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.

String ValuesConfiguration File in Phonegap with JQM for android

I am developing app for android using Phonegap with JQM. In J2ME app development , We can have centralized file ( message.txt ) we store list of string values which we are going to use. Like that can we have some configuration to get the string values from configuration file. So that we can easily do changes on text values. Could any one tell me.
Is it possible .?
There are numerous solutions, you only need to choose one that best serves your purpose.
Javascript solutions
All javascript solutions use localstorage as a final storage destination. Only difference is in their implementation, how far did they went to make it easier.
Lawnchair
Probably one of most commonly used JSON localstorage frameworks, also a framework of my choice. It is fast but probably a little bit confusing first time you see it. But with everything in mind it works very well.
Persistencejs
This is an another great solution. Best suited for mobile devices, but still made to work on broad specter of mobile devices (Android, iOS, BB) or desktop browsers. No matter which device is used it will use best storage available ranging from HTML5 WebSQL up to localstorage. This is an excellent solution if you want an easy way into WebSQL but it is a bit harder to work then HTML5 WebSQL.
localStorageDB
This one is a newcomer. Easy as Lawnchair but more SQL like. Like Lawnchair it uses only localstorage to store serialized JSON string. It will not work with webSQL.
Native support
Here you will also find fa few possibilities. A little bit better solution then JS frameworks, mainly because it used mobile phones native storage support.
Phonegap Storage
This is a official Phonegap support for local SQL storage. This is a commonly used functionality. But be warned it can be a little bit buggy. There's a support for every possible mobile platform except WM7+.
Cordova/PhoneGap sqlite plugin - Android version
Native interface to sqlite in a Cordova/PhoneGap plugin, working to follow the HTML5 Web SQL API as close as possible. It doesnt suffer from 5MB limit and it mimics classic SQL usage as close as possible. One thing to mention, it supports data encryption. Unlike common Phonegap Storage implementation this one supports Windows Mobile but BlackBerry is not supported.
Phonegap File
If you want to stick with files this solution is probably the best one. It is a common Phonegap solution. Store your configuration inside a XML and play with it in Java or Javascript.
Yeap, its possible to keep some string values in PhoneGap.
Since PhoneGap is based on HTML5 technology, you can make use of web storage (sessionStorage, localStorage) to store values.
Alternatively think of using native storage feature of the devices. You can store some config values in sqlite db and retrieve it when necessary.

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

Iphone and Android mobile development - Getting started

I'm a web developer in ASP.NET, C# and looking to start some mobile development. I'm aware Apple uses Objective C and Android uses Java, is there a way to create an app for both platforms or do I need to buy a Mac and some books on objective c and Java?
Thanks
You can use http://phonegap.com/ or http://www.appcelerator.com/platform to write cross-platform apps.
Rumour has it that Delphi XE3 (Due to come out soon) can be compiled onto Apple, Android, Windows 8 etc.etc. so if you can hold out a little longer that should be good!
For now, you are better using a mac (with XCode) to program for IOS or OSX as Apple is very particular and you need certificates for devices, projects, development and distribution etc.etc.etc.
Android i believe you have a bit more play with, but at the moment it is 2 seperate languages. Check out the DEV centres:
https://developer.apple.com
developer.android.com/
There are ways to create apps for both platforms, especially if you know web technologies : PhoneGap and others.
But like specified in the doc, you will most probably need an actual mac if you want to build to iOS
Although there are workarounds
You could use PhoneGap or Appcelerator. Haven't tried them myself, though. But with those tools you could build for both Android and iOS.
Since you are a .Net, C# developer, i recommend you to use Mono for Android, it comes with cost but will save you time and easy to deploy
http://xamarin.com/monoforandroid
The best way to be truly cross-platform is to develop for the web. I would include this in your consideration of development strategies, in addition to PhoneGap and Titanium, as Peter mentioned. You do not have as much access to core OS features, but that is improving all the time (see http://mobilehtml5.org/). Whether or not this is feasible depends on what you are trying to accomplish.

Categories

Resources