アクティビティの 1 つでデータベースにアクセスするための静的メソッドを作成しましたが、データベースを開くときにエラーが発生し続けます。
主な活動
public static String getStudentData() {
SQLiteDatabase sampleDB = null;
try {
//NOT WORKING
sampleDB = SQLiteDatabase.openDatabase("studentDB",null, SQLiteDatabase.CREATE_IF_NECESSARY);
//Also not working
//sampleDB = SQLiteDatabase.openOrCreateDatabase("studentDB", null);
Cursor c = sampleDB.rawQuery("SELECT * FROM student where id='1'", null);
if (c != null ) {
if (c.moveToFirst()) {
do {
//...
}while (c.moveToNext());
}
}
c.close();
} catch (Exception se ) {
} finally {
sampleDB.close();
}
}
その他の活動
String student = MainActivity.getStudentData();
私は得ていsqlite3_open_v2("studentDB", &handle, 6, NULL) failed
ます。何が問題なのかわかりません... も使用してみMODE_WORLD_WRITEABLE
ました。現在MODE_PRIVATE
、データベースの作成に使用しています。私を助けてください!