Note that there are some explanatory texts on larger screens.

plurals
  1. PONo duplicate in call log listview
    text
    copied!<p>Call log listview screen shot as i have got right now</p> <p>I just don't want duplicate values in my database. So that one contact name will be displayed single time in my listview and also I want number of calls associated with its number. I may get unique value by using unique keyword while inserting in database through query but i don't have any about counting a calls I get from that number.</p> <p>I am using following code to get call logs from database. Right now I am just accessing the call logs and displaying it. I have not stored in database.I just won't an idea how to count number of calls from particular number and show it in front it.As it is displayed in call logs applications.</p> <pre><code> Cursor callLogCursor = getContentResolver().query( android.provider.CallLog.Calls.CONTENT_URI, null, null, null, android.provider.CallLog.Calls.DEFAULT_SORT_ORDER); if (callLogCursor != null) { while (callLogCursor.moveToNext()) { String id = callLogCursor.getString(callLogCursor .getColumnIndex(CallLog.Calls._ID)); String name = callLogCursor.getString(callLogCursor .getColumnIndex(CallLog.Calls.CACHED_NAME)); String cacheNumber = callLogCursor.getString(callLogCursor .getColumnIndex(CallLog.Calls.CACHED_NUMBER_LABEL)); String number = callLogCursor.getString(callLogCursor .getColumnIndex(CallLog.Calls.NUMBER)); long dateTimeMillis = callLogCursor.getLong(callLogCursor .getColumnIndex(CallLog.Calls.DATE)); long durationMillis = callLogCursor.getLong(callLogCursor .getColumnIndex(CallLog.Calls.DURATION)); int callType = callLogCursor.getInt(callLogCursor .getColumnIndex(CallLog.Calls.TYPE)); String duration = getDuration(durationMillis * 1000); String dateString = getDateTime(dateTimeMillis); if (cacheNumber == null) cacheNumber = number; if (name == null) name = ""; Uri image = null; try { String conId = fetchContactIdFromPhoneNumber(cacheNumber); long contId = Long.parseLong(conId); image = getPhotoUri(contId); }catch(Exception e) { Log.e("Exception", e.getMessage()); } CallLogModel callLogModel = new CallLogModel(image, name, cacheNumber, duration, dateString); if (callType == CallLog.Calls.OUTGOING_TYPE) { outgoingList.add(callLogModel); } else if (callType == CallLog.Calls.INCOMING_TYPE) { incomingList.add(callLogModel); } else if (callType == CallLog.Calls.MISSED_TYPE) { missedcallList.add(callLogModel); } } callLogCursor.close(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload