Android 如何在安卓系统中统计最后日期收件箱短信
我正在开发一个应用程序,我想在其中计算最近一次的总日期Android 如何在安卓系统中统计最后日期收件箱短信,android,date,sms,inbox,Android,Date,Sms,Inbox,我正在开发一个应用程序,我想在其中计算最近一次的总日期收件箱短信。我正在使用这个代码 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 Str
收件箱短信
。我正在使用这个代码
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小时的收件箱短信,但我需要计算最后日期的收件箱短信。像今天一样,日期是2013年2月28日
,但我想统计一下2013年2月27日的收件箱短信总数
请帮助我,我是新学员,提前谢谢。尝试将选择设置为日期('now','1天')和日期('now')之间的
日期
,删除selectionArgs
更新:
Cursor cur = getContentResolver().query(uriSMSURI, projection, "datetime(date/1000, 'unixepoch') between date('now', '-1 day') and date('now')", null, null);
感谢您的回复,但我不明白如何实现程序。请将第8行更改为
Cursor cur=getContentResolver()。查询(urimsuri,投影,“日期之间的日期('now','-1天')和日期('now')”,null,null)代码>似乎从currentTimeMillis()开始,日期字段以毫秒为单位,答案可能是:Cursor cur=getContentResolver()。查询(urimsuri,projection,“datetime(date/1000,'unixepoch')介于日期('now','1天')和日期('now')”,null,null)代码>很好,最后一个工作正常。衷心感谢你,你真的很善良。再次感谢