安卓获取本地时间插入sqlite_从android中的sqlite数据库中获取字符串,日期,时间和int...

我使用此代码将字符串,日期,时间和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

这是我的代码来检索它

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 + "=?",new String[] { String.valueOf(id) },null);

if (cursor != null)

cursor.moveToFirst();

RemActions remActions = new RemActions(cursor.getString(0),cursor.getString(1),cursor.getString(2),cursor.getString(3),cursor.getInt(4));

// return remActions

return remActions;

现在我的ide给了我错误,因为我的RemAction类的构造函数中的第4个参数是java.util.date类中的Date类型.

我的问题是“我如何设置光标以日期格式获取它?”

生病了很高兴根据要求提供额外的代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值