CallLog.Calls查询按日期按日、CallLog、Calls

2023-09-05 10:28:48 作者:千年寒冰

我查询CallLog.Calls内容提供商的呼叫详细信息。一切工作正常,只是当我试图通过日期进行查询。也就是说,获得呼叫详细信息特定日期或日期范围等我知道的日期,只要(毫秒格式)存储,所以我想通过它的日期,然后再查询转换,但我一定要在这里做得不对。下面是我在运行查询,请注意,它工作得很好,当我删除了WHERE DATE =部分,或类似的东西取代它其中type =等,所以,我怎么运行一个查询来获取呼叫详细信息的日期或日期范围?任何帮助?谢谢。

 光标C = getContentResolver()查询(CallLog.Calls.CONTENT_URI,空,
               CallLog.Calls.DATE +&其中; =?,
                新的String [] {将String.valueOf(dateSTR)},ORDER_BY);
        startManagingCursor(C);
 

解决方案

这是我如何做到这一点:

 光标C = contentResolver.query(CallLog.Calls.CONTENT_URI,
                新的String [] {CallLog.Calls.DATE,CallLog.Calls.DURATION,
                        CallLog.Calls.NUMBER,CallLog.Calls._ID},
                CallLog.Calls.DATE +>?,
                新的String [] {将String.valueOf(resetDate.getTime())},
                CallLog.Calls.NUMBER +ASC);
 
Fake Call Log下载 安卓手机版apk 优亿市场

resetDate是一个日期变量,设定为i想覆盖的周期的开始。

I am querying CallLog.Calls content provider for call details. Everything works fine except when I try to query by dates. That is, to get call details for a particular date or date range etc. I know the date are stored as long (millisecond format) so I tried to convert the date first and then query by it, but I must be doing something wrong here. Here's the query I am running, pls note that it works well when I remove the "WHERE DATE =" part or replace it by something like "WHERE TYPE=" etc. So, how do I run a query to get call details for a date or date range? Any help on this? Thanks.

Cursor c = getContentResolver().query(CallLog.Calls.CONTENT_URI, null,
               CallLog.Calls.DATE + "<=?",
                new String[] { String.valueOf(dateSTR)}, ORDER_BY);
        startManagingCursor(c); 

解决方案

This is how i do it:

Cursor c = contentResolver.query(CallLog.Calls.CONTENT_URI,
                new String[] { CallLog.Calls.DATE, CallLog.Calls.DURATION,
                        CallLog.Calls.NUMBER, CallLog.Calls._ID },
                CallLog.Calls.DATE + ">?",
                new String[] { String.valueOf(resetDate.getTime())},
                CallLog.Calls.NUMBER + " asc");

resetDate is a Date variable, set to the beginning of the period i want to cover.