Android 删除sqlite数据库中早于特定天数的数据

Android 删除sqlite数据库中早于特定天数的数据,android,Android,我确实在互联网上搜索了相关信息并实施了。但不知何故,它在我的实现中不起作用。我喜欢删除超过一定天数的数据。 当我保存数据时,日期格式保存如下 SimpleDateFormat df = new SimpleDateFormat("EEE,d MMM yyyy,HH:mm:ss"); Date today = (Date) Calendar.getInstance().getTime(); String receiveDate = df.format(today); 我喜欢删除超过天数的数据,

我确实在互联网上搜索了相关信息并实施了。但不知何故,它在我的实现中不起作用。我喜欢删除超过一定天数的数据。 当我保存数据时,日期格式保存如下

SimpleDateFormat df = new SimpleDateFormat("EEE,d MMM yyyy,HH:mm:ss");
Date today = (Date) Calendar.getInstance().getTime(); 
String receiveDate = df.format(today);
我喜欢删除超过天数的数据,并按如下方式实现

    public boolean delete_oldData(int numofdays){
            String deleteQuery = "DELETE FROM " + SQLITE_TABLE + " WHERE " + KEY_TIMEINSTANCE +  " <= date('now','-" + numofdays + " day')";
            Log.d("Delete Query: ", deleteQuery);            
            myDb.execSQL(deleteQuery);         
            return true;
     }
public boolean delete\u oldData(整数天){
String deleteQuery=“从“+SQLITE\u TABLE+”中删除,其中“+KEY\u TIMEINSTANCE+”请尝试以下代码:

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, -numofdays);
String str = df.format(cal.getTime());

替换“如果将日期保存为字符串,则需要将其保存为long,或者使用njzk2在queryagree中解析日期,这样管理长值就容易多了,因为时间戳我的所有实现都是用字符串格式设置的。如果更改为long,我必须做很多更改。我该怎么办?谢谢我尝试了,它不起作用。现在我在r每行的日期比较。你能用<代替吗