如何在Android删除SQLite数据库旧行?
我有一个参数,其中用户可以选择时间数据的时间应存放于其中。
我在天
变量读它。日期和时间,当记录被添加到数据库存储在 KEY_DATE_ADDED
,这就像创建:
I have a parameter, where user can choose for which period of time data should be stored.
I read it in days
variable. Date and time, when record was added to the database is stored in KEY_DATE_ADDED
, it is created like:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // sql date format
Date date = new Date();
initialValues.put(KEY_DATE_ADDED, dateFormat.format(date));
然后我做到以下几点:
Then I do the following:
mDb.delete(DATABASE_TABLE,
"date(now) > date(" + KEY_DATE_ADDED + ",+" + days + " days)",
null);
和它不工作。实际的查询(其中一部分)是这样的:
and it doesn't work. Actual query (where part) looks like:
WHERE日期(现)>日期(DATE_ADDED,+ 10
天)
WHERE date(now) > date(date_added,+10 days)
什么是不正确吗?貌似不是 DATE_ADDED
别的东西应该在这里。
我想用 SQL数据格式化以避免重新格式化日期几次。
What is incorrect here? Looks like instead of date_added
something else should be here.
I wanted to use SQL data formatting to avoid re-formatting dates several times.
有没有GUI为Android数据库上的实际数据测试SQL查询?
Is there any GUI for Android database to test SQL queries on the actual data?
好吧,我应该使用日期('现在')GT;日期('DATE_ADDED','+ 10天)