安卓SQLiteException:近",":语法错误:在编制INSERT

安卓SQLiteException:近",":语法错误:在编制INSERT

问题描述:

我试图将值插入表

public class DatabaseHandler extends SQLiteOpenHelper {
    private final static String INSERT_INTO_COUNTRIES = "INSERT INTO " + TABLE_COUNTRIES
                + " VALUES";

    @Override
    public void onCreate(SQLiteDatabase db) {
            final String countries = "('1','Andorra','93','flag_andorra','AND'),
        ('2','Austria','43','flag_flag_austria','AUT')";
        String query = INSERT_INTO_COUNTRIES + countries + ";";
        db.execSQL(query);
    }

}

和收到以下错误:

android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: INSERT INTO cardberry_countries VALUES('1','Andorra','93','flag_andorra','AND'),('2','Austria','43','flag_flag_austria','AUT');

错误发生在Android 4.0.4的HTC Sense 3.6。 我测试了在多个设备上飞奔在Android 4.2及更高版本,它工作得很好。

Error occurs on Android 4.0.4 HTC Sense 3.6. I tested on multiple devices runnin on Android 4.2 and higher and it works fine.

有谁知道是什么问题?

多值语法是在SQLite 3.7 0.11

The multi-values syntax was introduced in sqlite version 3.7.11

sqlite的版本3.7.11仅在安卓4.1及以上

分裂您插入到不同的刀片,一排的时间。

Split your inserts into separate inserts, one row at a time.