4

In android development, and when is it good to use sql lite vs Web server db? If a person delete the app or upgrade my app then will the db get deleted if i use sql lite?

Thank you very much

Snake
  • 14,228
  • 27
  • 117
  • 250

3 Answers3

4

Use SQLite. Android comes with good support for it.

Usually the location for the database in Android is:

/data/data/[packagename]/databases

The sqlite database is just a file on the SDCard. It isn't tied to the app, so removing and or updating an app wont affect the database. (unless you wrote update code to update your db :) )

Sqlite is easy to use, compact, and obviously can be stored on your SDCard at ease. The ability to connect to it etc is all done in android.

You only need a web server database if you intend to share information from your app between devices/people. If the data is only necessary for your local device then definately use sqlite.

Gunnar Bernstein
  • 6,074
  • 2
  • 45
  • 67
IAmGroot
  • 13,760
  • 18
  • 84
  • 154
2

It won't be deleted. The method onUpgrade will get fired instead so you'll be able to check database versions and perform the proper changes to the current database (updates, data migrations, etc).

About having or not a service in the cloud to which you can sync it's a question that you have to answer yourself. These question could help you realize about the proper answer.

  • Does your product/service needs to share data across other apps?
  • Is your product/service going to be cross-platform?
  • Is it an advantage for your product/service to share data with other services?
Jose L Ugia
  • 5,960
  • 3
  • 23
  • 26
0

It depends on the application you are building. If you are looking to build an application that will be updating or saving data to a cloud then yes use mysql on a web server. If you are looking to build an application where data will only be available locally on the phone then use SQLite.

Proxy32
  • 711
  • 5
  • 18