You should change your Version of database to let it call the onUpgrade
method. Really, it should. And, the onCreate should not be called everytime.

It seems that your onUpgrade method is being called, and everytime you run
the app, it deletes all the tables and recreates them. That should explain
why your tables are empty. Check the logcat for more info. It should be
there.

Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



On Thu, Jan 13, 2011 at 5:22 AM, Tobiah <[email protected]> wrote:

> I took my code from the NotePad tutorial:
>
>        private static class DatabaseHelper extends SQLiteOpenHelper {
>
>                DatabaseHelper(Context context) {
>                        super(context, DATABASE_NAME, null,
> DATABASE_VERSION);
>                }
>
>                @Override
>                public void onCreate(SQLiteDatabase db) {
>
>                        Log.e(TAG, "CREATING DAG");
>                        createDB(db);
>                }
>
>                @Override
>                public void onUpgrade(SQLiteDatabase db, int oldVersion, int
> newVersion) {
>                        Log.e(TAG, "Upgrading database from version " +
> oldVersion + " to "
>                                        + newVersion + ", which will destroy
> all old data");
>
>                        db.execSQL("DROP TABLE IF EXISTS scan");
>                        db.execSQL("DROP TABLE IF EXISTS notes");
>                        db.execSQL("DROP TABLE IF EXISTS attendee");
>                        db.execSQL("DROP TABLE IF EXISTS
> attendeeqanswerlink");
>                        db.execSQL("DROP TABLE IF EXISTS lead");
>                        db.execSQL("DROP TABLE IF EXISTS leadnotes");
>                        db.execSQL("DROP TABLE IF EXISTS qanswer");
>                        db.execSQL("DROP TABLE IF EXISTS qquestion");
>                        db.execSQL("DROP TABLE IF EXISTS rolodex");
>                        db.execSQL("DROP TABLE IF EXISTS showinfo");
>
>                        onCreate(db);
>                }
>        }
>
> I can tell from the log that onCreate() is being called every time I start
> up my app.  onUpgrade() is not
> being called.  I can add data to the database using rawQuery().  While the
> app is running I can pull
> the database file to my dev box and select records from the copy.  If I
> restart the app, then pull
> the database, it's empty.
>
> What could be wrong?
>
> Thanks!
>
> Tobiah
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to