我创建了数据库,但是当我运行应用程序时,数据库没有创建,并且 catlog 中没有错误,请帮助我。并且在 fileexplorer/data/data 中没有创建文件夹名称数据库,并且当我在 MySQLiteHelper 中打印一些内容到控制台时,控制台上没有任何内容打印。请帮助我提前谢谢。
公共类 MySQLiteHelper 扩展 SQLiteOpenHelper {
public static final String TABLE_NAME_BOY = "question_boy";
public static final String ID_BOY = "_id";
public static final String QUESTION_BOY = "questions";
public static final String ANSWER_BOY = "answer";
public static final String TABLE_NAME_GIRL = "questions_girl";
public static final String ID_GIRL = "_id";
public static final String QUESTION_GIRL = "questions";
public static final String ANSWER_GIRL = "answer";
private static final String DATABASE_NAME = "bg.database";
private static final int DATABASE_VERSION = 3;
private static final String CREATE_TABLE_BOY = "create table "
+ TABLE_NAME_BOY + "(" + ID_BOY
+ "integer primary key autoincrement, " + QUESTION_BOY + " text, "
+ ANSWER_BOY + " text);";
private static final String CREATE_TABLE_GIRL = "create table "
+ TABLE_NAME_GIRL + "(" + ID_GIRL
+ "integer primary key autoincrement, " + QUESTION_GIRL + " text, "
+ ANSWER_GIRL + " text);";
public MySQLiteHelper(Context context, String name,
CursorFactory factory, int version) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(CREATE_TABLE_BOY);
db.execSQL(CREATE_TABLE_GIRL);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
Log.w(MySQLiteHelper.class.getName(),
"Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS" + TABLE_NAME_BOY);
db.execSQL("DROP TABLE IF EXISTS" + TABLE_NAME_GIRL);
onCreate(db);
}
}