What after creating SQLite database ?

0 Mohamed Elkady · March 4, 2015
Hi guys, 
now, i created a simple database called library to stores books(id, title, author_name).
the question is : "Did the app creates the database each time the app starts on my device?, and if there any way to create the database just one time and each time i open the app just add to database ( or manage update records as i want)  not to create it again"

thanks in advance.

Post a Reply

Replies

Oldest  Newest  Rating
0 Branislav Lazic · March 4, 2015
No, database is created only once if it doesn't exist. However, if you are not careful, your tables could be recreated each time.
Therefore, use this "CREATE" statement:


CREATE TABLE IF NOT EXISTS table_name......

You can run that statement each time upon application startup. Tables will be created only if they don't exist (at first startup).
0 Mohamed Elkady · March 4, 2015
Thanks Branislav 
  • 1

Java / Android Development

107,133 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator