CallLog.Calls._COUNT

时间:2013-01-24 12:45:13

标签: android android-contentprovider

在Android文档(内容提供商)中,CallLog.Calls._Count是BaseColumns的一部分,但在运行此代码时,logcat会显示无效的列_COUNT:

    String[] projection = new String[] { CallLog.Calls._COUNT };

    Cursor cursor = this.getContext().getContentResolver().query(CallLog.Calls.CONTENT_URI, projection, null, null, null);

请参阅此问题:http://code.google.com/p/android/issues/detail?id=1343

由于

1 个答案:

答案 0 :(得分:0)

由于您只对目录中的行数感兴趣,因此您无需预测_COUNT,请尝试以下操作:

int count;
Cursor cursor = this.getContext().getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, null);
if(cursor.moveToLast())
   count = cursor.getPosition();

我不确定您是否可以在_COUNT中找到CallLog.Calls.CONTENT_URI列。如果您对上述答案不满意,请尝试通过迭代列索引查找Cursor中的所有列名。