今天必须写下这篇日志,这个错出得太冤枉,浪费了太多时间。
public class DiamondDataBase extends SQLiteOpenHelper {
public DiamondDataBase(Context context, String dbpath) {
super(context, null, null, SCHEMA_VERSION);
c = context;
setDatabaseName(dbpath);
}
public boolean tabbleIsExist(String tableName) {
boolean result = false;
if (tableName == null||tableName=="") {
return false;
}
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = this.getReadableDatabase();
String sql = "select count(*) from Sqlite_master where type ='table' AND name ='"
+ tableName.trim() + "' ";//as c
cursor = db.rawQuery(sql, null);
if (cursor.moveToNext()) {
int count = cursor.getInt(0);//cursor.getCount();//.
if (count > 0) {
result = true;
}
}
} catch (Exception e) {
// TODO: handle exception
} finally {
cursor.close();
db.close();
}
return result;
}
}
构造时不将path传到超类,是想在子类中灵活地操作,更符合自己以前操作ODB的习惯,但后面又用了超类的方法,结果一直不知道自己是在操作“:memory:”这个数据库