我的表是用
db.execSQL(
"CREATE TABLE periods (" +
" vehicle_id INTEGER KEY," +
" line_id INTEGER KEY," +
" period_id INTEGER PRIMARY KEY AUTOINCREMENT," +
" line_code STRING," +
" sup_code STRING," +
" start_date INTEGER," +
" end_date INTEGER" +
")"
);
并插入数据
ContentValues values = new ContentValues();
values.put("vehicle_id", 1);
values.put("line_id", 2);
values.put("line_code", "0406");
values.put("sup_code", " ");
values.put("start_date", 1);
values.put("end_date", 24);
db.insert("periods", null, values);
但是当我检索数据时
Cursor cPeriods = db.rawQuery("SELECT * FROM periods WHERE vehicle_id=" + vehicleId, null);
System.err.printf("SQLite: ### Get line_code = \"%s\"\n", cPeriods.getString(3));
结果总是“406”
如何解决这个问题?我不想做一个丑陋的修复,例如在插入之前在“0406”前面放一些符号,然后在检索后将其删除。