sqlite execSQL(sql, bindArgs) 第二个参数不自动替换的问题
    public static final String USER_TABLE_NAME = "user";
    public static final String USER_TABLE_FIELD_ID = "id";
    public static final String USER_TABLE_FIELD_PASSWORD = "password";

    public static final String DEVICE_TABLE_NAME = "device";
    public static final String DEVICE_TABLE_FIELD_ADDRESS = "address";
    public static final String DEVICE_TABLE_FIELD_NAME = "name";

    public static final String LASTCONNECT_TABLE_NAME = "lastConnect";
    public static final String LASTCONNECT_TABLE_FIELD_ID = "id";
    public static final String LASTCONNECT_TABLE_FIELD_ADDRESS = "address";

 public void onCreate(SQLiteDatabase db)
    {
        String sqlString = "create table ? (? verchar(50) primary key, ? verchar(50))";
        db.execSQL(sqlString, new Object[]{USER_TABLE_NAME, USER_TABLE_FIELD_ID, USER_TABLE_FIELD_PASSWORD});
        db.execSQL(sqlString, new Object[]{DEVICE_TABLE_NAME, DEVICE_TABLE_FIELD_ADDRESS, DEVICE_TABLE_FIELD_NAME});
        db.execSQL(sqlString, new Object[]{LASTCONNECT_TABLE_NAME, LASTCONNECT_TABLE_FIELD_ID, LASTCONNECT_TABLE_FIELD_ADDRESS});
    }

2个回答

android.database.sqlite.SQLiteException: near "?": syntax error (code 1): , while compiling: create table ? (? verchar(50) primary key, ? verchar(50))

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问