0

在 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

谢谢

4

1 回答 1

0

Since you are interested in only the number of rows in the directory, you don't need to project the _COUNT, try this:

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

I'm not sure if you can find _COUNT column in CallLog.Calls.CONTENT_URI. If you are not satisfied with my answer above, try finding all column names in the Cursor by iterating column indexes.

于 2013-01-24T12:54:53.780 回答