0

我有以下代码:

    ArrayList NumList = getIntent().getParcelableArrayListExtra ("name");
    ArrayList<String> results = new ArrayList<String>();
    SQLiteDatabase sampleDB = null;

    try {
        sampleDB =  this.openOrCreateDatabase(SAMPLE_DB_NAME, MODE_PRIVATE, null);

        sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " +
                SAMPLE_TABLE_NAME +
                " (FirstName VARCHAR);");

        sampleDB.execSQL("INSERT INTO " +
                SAMPLE_TABLE_NAME +
                " Values (NumList);");

我想要做的是将 NumList 传递到表中。上面的代码显示一个错误,说“没有这样的列:NumList)”我将如何传递这些信息?

4

2 回答 2

2

试试这个:

sampleDB.execSQL("INSERT INTO " +
            SAMPLE_TABLE_NAME +
            " ( FirstName ) Values ('"+NumList+"');");
于 2012-08-14T08:54:55.217 回答
2

试试这个:

for(String str: NumList){
sampleDB.execSQL("INSERT INTO " +
            SAMPLE_TABLE_NAME +
            " ( FirstName ) Values ('"+str+"');");
}
于 2012-08-14T09:12:42.457 回答