When and why to use database in Mobile Applications

0

I know that this is not a specific question, which is based on opinions but does not find a better way to know or understand why and when to occupy a database within a mobile application.

I work in many native Android applications and hybrid with Ionic framework, and in most of the hybrid applications that I have done I have worked without a database, only occupying services, factories, that help me with the localStorage and multiple validations for I can achieve certain "persistence" within my application.

I recently participated in a Xamarin course in which we were taught to use the Microsot Azure web services, where most of the applications were powered by data in JSON format and not a relational database such as SQL. I used to handle traditionally with Microsoft.

On the other hand, all the applications that I have done natively I have worked with databases because besides consuming web services, there is a different logic of the treatments that are made to the data to manage and send again to the server if it is the case. Now, I know that by saying:

  

Database because in addition to consuming web services, there is a different logic of the treatments that are made to the data to manage and send back to the server

I answer a little bit my question, but I want to know what is correct in this case, if it will be correct to load the localStorage with data to search and access them or it is advisable to always use a database to make the persistence.

I insist again, I know that it is not a specific question, that maybe there is not an error in the middle, but to your experience I would like to orientate myself regarding this concern.

    
asked by sioesi 01.12.2016 в 14:58
source

1 answer

1

I would recommend that you not try to use the localStorage as a database. Why? First, because you can not assume that it will work 100%. According to this article and which in turn directs at Ionic Official Forum There are certain bugs in both large platforms (iOS and Android). In addition, there is a limit that I think is 10MB. In addition, you would have to handle serializations, searches, etc., within a string . There are alternatives like PouchDB working with JSON or Cordova plugins .

EDIT

Maybe I said things you already knew but well, you accepted that your question is still a bit on the air. I'll try to plumb.

  

When and why use a database in Mobile Applications?

Depends on your type of application

There are apps that do all the work in the front, others are just a view that reflects the backend. For some you need data persistence. For others not. That ends up deciding you. If you plan to market your app at some point you will have to implement it in the backend and that is why the tutorial has a section of Azure Services. If your app requires sensitive user information, even more. Now, it does not mean that you should store everything in the front. In fact all authentication and verification tasks have to fall on the server side because it is the only thing you can control 100% for reasons that we think we all know.

Then consider: do you want to depend on when the user needs some data have to talk to your backend or prefer certain saved data? If it's just a string or a logic that does not mean much, use the localStorage. If it is one or more sensitive objects, it is better to opt for a database or a simple configuration file.

Detail that I forgot to mention and is not very clear in many tutorials

  

you can only save strings in the localStorage

That's why I mentioned serialization. I hope I've brought you something else with this.

    
answered by 01.12.2016 / 19:49
source