这是我onCreate
方法中存在的db类的片段。在此方法之上定义了一个具有适当参数的构造函数。
因此,在运行它时,此方法的运行时日志表明它执行了 run1.2 ,但没有进一步执行。
public void onCreate(SQLiteDatabase db) {
try{
db = getWritableDatabase();
db.beginTransaction();
android.util.Log.w("check", "run1.1");
String query = " CREATE TABLE check ( id INTEGER )";
android.util.Log.w("check", "run1.2");
db.execSQL(query, null);
android.util.Log.w("check", "run1.3");
}
catch(Exception e){
android.util.Log.w("check", e.toString());
}
}
答案 0 :(得分:1)
删除execSQL
来电的第二个参数。这是来自SQLiteDatabase.java的execSQL代码:
public void execSQL(String sql, Object[] bindArgs) throws SQLException {
if (bindArgs == null) {
throw new IllegalArgumentException("Empty bindArgs");
}
executeSql(sql, bindArgs);
}
仅限使用:
db.execSQL(query);