我創建數據庫,但是當我運行該數據庫沒有創建應用程序並且在沒有目錄下載錯誤,請幫我不會創建SQLite數據庫。 並在fileexplorer /數據/數據有沒有創建文件夾的名稱數據庫 還當我在MySQLiteHelper打印一些東西到控制檯上的Console類沒有打印。 請提前幫助我。在我的文件瀏覽器中文摘
公共類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);
}
}
如何根設備? – 2012-07-26 10:19:55
只是我想創建一個空數據庫,但如果你希望你的sqlite的文件,那麼你可以在模擬器上運行的應用程序,你的數據庫文件沒有數據文件夾 – 2012-07-26 10:20:46
創建.. – 2012-07-26 10:26:06