![]() Still just as valid for PhoneGap as for desktop browsers. I think that the best introductionary text on that topic can be found in Mark Pilgrim's "Dive into HTML5": Web SQL databases are one implementations of what's more broadly referred to as "local storage". It will work exactly the same in PhoneGap as in desktop browsers. In Chrome or Safari, you can go have a look at it's contents with your developer tools, look at the 'Resources' tab -> Databases (you want to test out basic functionality on a desktop browser before trying in PhoneGap). In reality, it's based on SQLite in most browsers that support it, but it won't be exactly the SQLite implementation. ![]() You want what's called a 'Web SQL Database'.Įdit: This specification has been marked as deprecated since the writing of this answer and it's now an officially Bad Idea™ to depend on it. ![]() Everything that applies to mobile WebKit will apply to PhoneGap as well, and the environment in PhoneGap is also very similar to opening an HTML-file in a desktop browser. It's important to remember that PhoneGap is web apps packaged in a browser component. Unfortunately, the plugin doesn't provide exactly the same javascript interface as the browser, but it's fairly close. So we went with using the PhoneGap SQLite plugin instead: This allowed us to include a large pre-populated sqlite3 database in our app and access it from javascript via the plugin. However, in our latest attempt to submit the app, we were told the app violated iOS Data Storage Guidelines, presumably because it was copying the database file to a non-standard location. We initially worked around this issue by copying a pre-populated sqlite3 database to a special directory where it would be picked up by WebKit (e.g. Pre-populating the database via javascript adds to initial app load time.Size of database is limited to 5MB (the user can be prompted to allow more, but we didn't want such prompts in our app).We started off using a plain old Web SQL Database in our PhoneGap app, but ran into the following limitations: Return this._db.We ended up using the PhoneGap SQLite plugin, here's why: Note: SQLite is slower than IndexedDB/WebSQL as mentioned in this article by Nolan Lawson. this is no longer the case, I've updated this tutorial to include the extra steps needed to use SQLite on the mobile devices. PouchDB will automatically use SQLite if you have installed a Cordova plugin for it and have configured it to use a WebSQL adapter. ![]() There are storage limits for IndexedDB and WebSQL databases, so if you want unlimited and reliable storage on a mobile device, you're better off using SQLite. And then there is the out-of-the-box syncing with a server, but in this tutorial, we'll only focus on local storage. What I like about PouchDB is that it uses a NoSQL approach to database storage, which greatly simplifies the code you need to write. It's inspired by Apache CouchDB and allows you to sync your local data with a CouchDB server. PouchDB is an open-source JavaScript library that uses IndexedDB or WebSQL to store data in the browser. I recommend you read my new tutorial using ngrx and Observables after you're finished with this one.= =Update: In this tutorial, I'm using Promises for the CRUD operations on PouchDB. =Update: The code in this tutorial is now up to date with Ionic 2.0.0-rc.4 (December 2016)= Now that Ionic 2 is in beta, I've updated the tutorial for Ionic 2 and the recently released Cordova SQLite Plugin 2. 18 April 2016 PouchDB, SQLite, Ionic 2+, Angular 2+, TypeScript, Local StorageĪ year ago I wrote a tutorial on how to use PouchDB + SQLite for an Ionic 1 app.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |