我正在使用sqlite数据库。我使用以下代码在数据库中存储三个值。
sampleDB = this.openOrCreateDatabase(SAMPLE_DB_NAME, MODE_PRIVATE, null);
sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " + SAMPLE_TABLE_NAME
+ " (rowid INT , songname VARCHAR," + " count INT);");
int len = songlist.size();
Log.v("songlist len", Integer.toString(len));
for (int s = 0; s < songlist.size(); s++) {
sampleDB.execSQL("INSERT INTO " + SAMPLE_TABLE_NAME +
" Values (1,"+songlist.get(s)+",1);");
Log.v("After insert", "1");
}
我收到以下错误
01-13 20:58:08.903: E/AndroidRuntime(593): Caused by: android.database.sqlite.SQLiteException: no such column: android: INSERT INTO freq Values (1,android,1);
需要帮助。
答案 0 :(得分:1)
试试这个。也许你必须为字符串输入添加引号
Values (1,\""+songlist.get(s)+"\",1);");