I'm trying to get a list of the user's calls and I'm getting the illegalargumentexception: column '_id' does not exist.
This I find really weird because I did not create or have anything to do with the call Log table, I'm just trying to query it. Here's my code:
String[] strFields = {
android.provider.CallLog.Calls.NUMBER,
android.provider.CallLog.Calls.TYPE,
android.provider.CallLog.Calls.DATE,
android.provider.CallLog.Calls.DURATION
};
String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
callCursor = getContentResolver().query(
android.provider.CallLog.Calls.CONTENT_URI,
strFields,
null,
null,
strOrder
);
// THE DESIRED COLUMNS TO BE BOUND
String[] columns = new String[] { android.provider.CallLog.Calls.DATE,
android.provider.CallLog.Calls.DURATION,
android.provider.CallLog.Calls.TYPE,
android.provider.CallLog.Calls.NUMBER };
... and then I do some ListView/cursor adapter stuff.
So is there something I'm doing wrong here in this query? Are there any alternate solutions to accessing the call log?
Thanks.
If you're using a CursorAdapter then the callCursor must include a column named "_id", otherwise the adapter will not work (CursorAdapter)
You should add this String to your strFields array
android.provider.CallLog.Calls._ID
Then your CursorAdapter should work as expected