android中获取通话记录

来源:互联网 发布:sql主键自增长 编辑:程序博客网 时间:2024/05/17 01:08


转自:http://blog.163.com/llllamso_0819@126/blog/static/647443192010111753159614/

String str = "";

        int type;
        long callTime;
        Date date;
        String time= "";
        ContentResolver cr = getContentResolver();
        final Cursor cursor = cr.query(CallLog.Calls.CONTENT_URI, new String[]{CallLog.Calls.NUMBER,CallLog.Calls.CACHED_NAME,CallLog.Calls.TYPE, CallLog.Calls.DATE}, null, null,CallLog.Calls.DEFAULT_SORT_ORDER);
        for (int i = 0; i < cursor.getCount(); i++) {   
            cursor.moveToPosition(i);
            str = cursor.getString(0);
            str = cursor.getString(1);
            type = cursor.getInt(2);
            SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            date = new Date(Long.parseLong(cursor.getString(3)));
            time = sfd.format(date);
           }
原创粉丝点击