1

我正在开发一个应用程序,我想在其中计算最后一个日期总数inbox SMS。我正在使用此代码

TextView view = new TextView(this);
Uri uriSMSURI = Uri.parse("content://sms/inbox");
long now = System.currentTimeMillis();
long last24 = now - 24*60*60*1000;//24h in millis
String[] selectionArgs = new String[]{Long.toString(last24)};
String selection = "date" + ">?";
String[] projection = new String[]{"date"};
Cursor cur = getContentResolver().query(uriSMSURI, projection, selection, selectionArgs,null);
String sms = String.valueOf(cur.getCount());
view.setText("Total incoming today SMS  "+sms);
setContentView(view);

我可以计算过去 24 小时的收件箱短信,但我需要计算最后日期的收件箱短信。像今天一样,Date is 28/02/13但我想计算总收件箱短信Date 27/02/13

请帮助我,我是新手,在此先感谢。

4

1 回答 1

3

尝试将选择设置为date between date('now', '-1 day') and date('now'),删除selectionArgs

更新:

Cursor cur = getContentResolver().query(uriSMSURI, projection, "datetime(date/1000, 'unixepoch') between date('now', '-1 day') and date('now')", null, null);
于 2013-02-28T09:00:54.000 回答