Why SQLiteOpenHelper onCreate() Is Not Called

This method is actually called automatically whenever the SQLiteOpenHelper methods getWritableDatabase() or getReadableDatabase() is/are called.

You cannot call this manually.

The reason for this being that the database is already created. If you want onCreate() to be called again, you can delete the database and run your app again.

To do so in Eclipse, do the following:

  1. Go to Window > Show View > Android > File Explorer
  2. Go to data folder
  3. Look for your app’s package name, the database should be there

If you are the hardcore type, you can use the adb shell command. Log into the shell and then use the “rm” command to delete your database file.

Or, just uninstall your app from the Android emulator. This removes not only the app, but your database as well.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *