Ng'esh Ng'esh - 1 year ago 145
Android Question

Intel XDK: Connecting your mobile app to a database

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 Source

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:

2- You can use server database like MySQL or SQL server. however you need to connect your html codes to a PHP or 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 however will be fully retired on January 28, 2017.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download