Intel XDK: Connecting your mobile app to a database

Ng'esh picture Ng'esh · Apr 3, 2014 · Viewed 29k times · Source

I am currently developing an application which if I don't have a database, the application after building will be heavy. How do I connect the application to a database, either local or remote?

Thanks in advance.

Answer

Iman Sedighi picture Iman Sedighi · May 27, 2014

You can use one of the following methods for using database:

1- Using HTML5 client side databases. HTML5 provides four different types of Storage of data on a local client's machine. They are

Local Storage. Web SQL Storage. Session Storage Indexed DB

It depends on your demands you can use one of them. If you need a persistent database for saving values less than 5 Mb, I recommend you LocalStorage as implementation of that is very easy. The data you saved in HTML5 localstorage will not be deleted even in case of phone shut down or reset. The data will be deleted only when you remove it by localStorage.removeItem(); Client side database is not recommended if you have huge amount of data or you need a central database which you should show to everybody who use this app in the world. in these cases its better, you use server side database

You can read a very nice article about how to use html5 local databases in XDK website: https://software.intel.com/en-us/articles/html5-local-storage

2- You can use server database like MySQL or SQL server. however you need to connect your html codes to a PHP or asp.net script in a server by AJAX. You may use JSON for transfer data from PHP in server side to JS in the client side.

3- You can use cloud databases like Parse.com however Parse.com will be fully retired on January 28, 2017.