I am using this code to show missed calls in my application while I am using Call class to define an object each time then store it in test how Can I print all objects in test list in my application?
List<Call> callList = new ArrayList<Call>();
while (c.moveToNext()) {
Call call = new Call();
call.setNumber(c.getString(c.getColumnIndex(CallLog.Calls.NUMBER)));
/* if (c.getInt(c.getColumnIndex(CallLog.Calls.TYPE)) == CallLog.Calls.OUTGOING_TYPE) {
call.setOut(true);
} else {
call.setOut(false);
}*/
call.setName(c.getString(c.getColumnIndex(CallLog.Calls.CACHED_NAME)));
call.setTime(c.getLong(c.getColumnIndex(CallLog.Calls.DATE)));
call.setDuration(c.getLong(c.getColumnIndex(CallLog.Calls.DURATION)));
if ( c.getString(c.getColumnIndex(CallLog.Calls.CACHED_NAME))!= null)
{
continue;
}
callList.add(call);
}
c.close();
}
you can override toString()
method on Call
class like:
@Override
public String toString() {
return Name+" "+Time+" "+Duration;
}
and print your list in for statement like:
for (int i = 0 ; i < callList.size() ; i++)
Log.d("value is" , callList.get(i).toString());
You can just iterate through the list and print the elements :
List<Call> callList = new ArrayList<Call>();
for(Call call : callList){
System.out.print("Name - " +call.getName() +
"Number - "+call.getNumber() +
"Time - "+call.getTime() +
"Duration - "call.getDuration());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With