Cursor c = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, null);
for (int i = 0; i < c.getColumnCount(); i++) {
Log.i(getClass().getName(), "retrieveCall(): " + c.getColumnName(i));
}
I can get all colume names in 4.0.x, but only got _id under 4.0.x. What 's the matter with my code? Thx in advance!
Cursor c = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, null);
for (int i = 0; i < c.getColumnCount(); i++) {
Log.i(getClass().getName(), "retrieveCall(): " + c.getColumnName(i));
}
while (c.moveToNext()) {
for (int i = 0; i < c.getColumnCount(); i++) {
Log.i(getClass().getName(), "retrieveCall(): " + c.getColumnName(i) + " = " + c.getInt(i) + "/" + c.getString(i));
} ...
code above works well in 4.0.x, I guess there are some differences of database?
@Anu, this is my complete code, please kindly tell me if you found somthing wrong:
private void retrieveCall()
{
Cursor c = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, null);
if (c != null) {
while (c.moveToNext()) {
String number = c.getString(c.getColumnIndex("number"));
String name = c.getString(c.getColumnIndex("name"));
long date = c.getLong(c.getColumnIndex("date"));
if (number.length() > 0) {
LogDetail log = null;
if (_callTable.containsKey(number)) {
log = (LogDetail) _callTable.get(number);
log.name = name;
log.date = date;
log.amount++;
} else {
log = new LogDetail();
log.name = name;
log.date = date;
log.amount = 1;
}
_callTable.put(number, log);
}
}
c.close();
}
}
try this ..... It worked for me...
Cursor c1 = getContentResolver().query(CallLog.Calls.CONTENT_URI,null,null,null,null);
for(int i=0;i<c1.getColumnCount();i++){
Log.i("Column name", ""+c1.getColumnName(i));
}