我使用此代码将字符串,日期,时间和int值插入sqlite数据库
void addRemAction(RemActions remaction) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_ACTOINS_TITLE, remaction.getTitle()); // Action title
values.put(KEY_ACTIONS_MSG, remaction.getMsg()); // action msg
values.put(KEY_ACTIONS_DATE, dateFormat.format(new Date())); // action date
values.put(KEY_ACTIONS_TIME, remaction.getTime()); // action time
values.put(KEY_ACTIONS_PLACE_LONG, remaction.getPlong()); // action place long
values.put(KEY_ACTIONS_PLACE_LAT, remaction.getPlat()); // action place lat
// Inserting Row
db.insert(TABLE_ACTIONS, null, values);
db.close(); // Closing database connection
Run Code Online (Sandbox Code Playgroud)
这是我的代码来检索它
RemActions getRemAction(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_ACTIONS, new String[] {KEY_ACTOINS_TITLE, KEY_ACTIONS_MSG, KEY_PLACES_NAME, KEY_ACTIONS_DATE, KEY_ACTIONS_TIME}, KEY_ACTIONS_ID + …Run Code Online (Sandbox Code Playgroud)