我正在尝试在我的 SQLiteOpenHelper 文件中使用它来检查是否存在表和带有 Android 的 SQLite 数据库
// Check to see if a table exists
public boolean isTableExists(String tblName) {
String existQuery = "SELECT name FROM sqlite_master WHERE name ='" + tblName + "' and type='table'";
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(existQuery, null);
if(cursor != null){
cursor.close();
return true;
}
return false;
}
我的活动的电话是
if(db.isTableExists("characters") == false){
Intent p = new Intent("com.tml.rpgtodo.CREATECHARACTER");
startActivity(p);
}
我在 if 语句的行上不断收到 NullPointerException。我究竟做错了什么?