I have tried the below code in Custom List View.I tried to replace Call type with "Incoming","Outgoing" and "missed" it is showing Number Format Exception: For Input String "type"
assert cr != null;
if (cr.moveToLast()) {
for (int i = 0; i < cr.getCount(); i++) {
CallLogData cons = new CallLogData();
cons.setNumber(cr.getString(cr.getColumnIndex(CallLog.Calls. NUMBER)));
cons.setType(cr.getString( cr.getColumnIndex(CallLog.Calls. TYPE)));
callsListView.add(cons);
cr.moveToPrevious();
}
String dir = null;
int dircode = Integer.parseInt(getString(Integer.parseInt(CallLog.Calls. TYPE)));
switch (dircode) {
case CallLog.Calls.OUTGOING_TYPE:
dir = "OUTGOING";
break;
case CallLog.Calls.INCOMING_TYPE:
dir = "INCOMING";
break;
case CallLog.Calls.MISSED_TYPE:
dir = "MISSED";
break;
}
sb.append("\n ").append(dir);
}
cr.close();
This line where i am getting an error
int dircode = Integer.parseInt(getString(Integer.parseInt(CallLog.Calls. TYPE)));
CallLog.Calls. TYPEis the string"type", soInteger.parseInt("type")throws exception. Perhaps the secondInteger.parseIntcall in that line should be removed?int dircode = Integer.parseInt(cr.getString(cr.getColumnIndex(CallLog.Calls.TYPE)));?