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.

If you encounter this error message, I figure you used the requestWindowFeature() method in a class that already inherits from Activity. Say, PreferenceActivity perhaps?

While the rule to use this method should be before one sets the content view of the Activity, in the case of a PreferenceActivity class, it is different.

Since super.onCreate() is called, the ViewGroup is set up so you are not allowed to change the Window‘s parameters.

The workaround for this is to call the requestWindowFeature() method first before super.onCreate(). That should fix it.

There is a big chance that you did this within the onCreate() method of the Activity class and you wondered why if with the click of the button, it works.

I read a post from the Stack Overflow forum that the start() method called on the AnimationDrawable cannot be called during the onCreate() method of your Activity because the AnimationDrawable is not yet fully attached to the window.

A good suggestion by user will is to create an inner class where you trigger the start() method of the AnimationDrawable. Try the sample inner class below in your class. It should work.

Related Posts Plugin for WordPress, Blogger...