Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why to use sqlite Database in Android?

Why do we use the sqlite data base in android.I am developing an android application where the data is to be fetched from the server and do some data calculation and show it on the UI.

Is it good for me to fetch the data into the sqlite DB and update the UI on regular interval from the sqlite in evry 20 minutes or will it be good to sent the Http get request to the server and update the data from teh response on the UI.

I wanted to know which one will be better and why?Why to involve sqlite DB? The data corresponds to some 40X40 table data on which some heavy mathematical processing is to be done and then displayed on the UI(similar to Stock market application) and data needs to be cleared after every 12 hours. plz advice Rgds, Raul

like image 498
Raulp Avatar asked Apr 26 '12 08:04

Raulp


People also ask

Is SQLite good for Android?

SQLite is cross-platform which means that it can be used on Android application built on Java, and as well as cross-platform application built on React Native.

Why do we use SQLite database?

SQLite is self-contained means it requires minimal support from the operating system or external library. This makes SQLite usable in any environment especially in embedded devices like iPhones, Android phones, game consoles, handheld media players, etc.

What is SQLite database in Android?

SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC,ODBC e.t.c.


1 Answers

It is good to use database in your case.

Pros:

  • If your application gets closed the in memory data will be lost, but after that you will be able to restore the state from the database if you have one
  • Especially for the case of complex calculations it is good to store the result once in the database and not recalculate it multiple times on demand
  • The database will untie your UI from the internet connection and thus you will be able to display results even if there is not internet connection
  • Using database you will be able to fetch the updated data from a background service, without impacting your UI
  • Organizing your data in database usually makes it a lot easier to manage all the application data.

Cons:

  • Adding database will require a bit of additional effort on your side

As you can see my list proves you SHOULD use database in your case. Maybe I am biased, but at least I provide you with things to consider.

like image 172
Boris Strandjev Avatar answered Oct 11 '22 02:10

Boris Strandjev