0

Am a newbie to android development. I would like to have suggestions for setting up database during installation and populate the data in the tables.

As tables creation, data population in tables is a one time process which will be done during App installation, how can we write a program which will meet this requirement.

Thanks in advance!

ConcurrentHashMap
  • 4,998
  • 7
  • 44
  • 53
  • See this link: http://stackoverflow.com/questions/513084/how-to-ship-an-android-application-with-a-database – Ayub Jul 04 '14 at 07:24

1 Answers1

0

You cannot setup database during installation. You can however do one of two things:

  1. Ship your application with a ready made database.
  2. Have your database created for you the first time it is needed.

If you prefer to go with option 1, you should extend an application class and have your databases created for you on the onCreate() call there. Refer to this for help. If you want to use option 2, you should understand the database lifecycle, most important thing being, when you are trying to access your database but it is not there, the system calls the onCreate() method of the class that extends SQLiteOpenHelper class. Refer to this url.

Bijay Koirala
  • 525
  • 5
  • 9