SQLiteOpenHelper “onCreate” is not called? (the DB does not exist)

前端 未结 5 1127
[愿得一人]
[愿得一人] 2021-01-19 21:54

From a fragment I instantiate this way

fmdata = new FileManagerData(getActivity());

the following class. I don\'t understand why onCreate()

5条回答
  •  渐次进展
    2021-01-19 22:36

    You should put in onCreate this:

    sqLiteDatabase.execSQL("create table" + DB_NAME + " ( _id integer primary key autoincrement, " + fieldOne + "INTEGER, " + fieldTwo + "INTEGER);");
    

    Where fieldOne and fieldTwo are names of your table's columns. Also look here: http://www.sqlite.org/datatype3.html

提交回复
热议问题