我正在开发一个应用程序,我想计算最后日期总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
的收件箱短信总数。
请帮助我,我是一个新学习者,提前感谢。
尝试将选择设置为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);