In SQLiteOpenHelper, the meaning of 'onCreate' is different from what it is in an Activity. Here,'onCreate' is called only once, which is the first time you create the database. The next time you run the app, the database is already there, so it won't call 'onCreate'.
Your object level initialization should be done in the constructor and not in 'onCreate.
Up vote 0 down vote favorite share g+ share fb share tw.
This is the fist time I've used SQLiteOpenHelper (or databases on android). When I get a writeable database I was wondering why onCreate isnt being called on each new instance of the class. Am I doing something wrong?
Public class DatabaseHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "MyDatabase. Db"; private static final int DATABASE_VERSION = 1; private String PrSQLcmd = ""; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db. ExecSQL("CREATE TABLE IF NOT EXISTS Contact(Firstname TEXT, LastName TEXT"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } } android sqlite oncreate sqliteopenhelper link|improve this question edited Nov 15 '11 at 17:23 asked Aug 23 '11 at 16:24CrimsonChin3798 92% accept rate.
May be you already have database, so it doesn't call onCreate. – Nikita Beloglazov Aug 23 '11 at 16:43 You were completely correct, I was forgetting it simply looked at the database NOT the tables I was trying to add. Worked perfectly.
– CrimsonChin Aug 24 '11 at 9:04.
In SQLiteOpenHelper, the meaning of 'onCreate' is different from what it is in an Activity. Here,'onCreate' is called only once, which is the first time you create the database. The next time you run the app, the database is already there, so it won't call 'onCreate'.
Your object level initialization should be done in the constructor and not in 'onCreate' To see 'onCreate' being called, either manually delete the db file, or simply uninstall the app.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.