Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
944 views
in Technique[技术] by (71.8m points)

web services - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...