Getting call records in android
<p>I have used Calllogs.calls method and fetched the contact and the details but i am getting all the call records in a single string Using this code.</p>

<pre><code>  private void getCallDetails() {

    StringBuffer sb = new StringBuffer();
    if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {

        return;
    }
    Cursor managedCursor = getActivity().getContentResolver().query(CallLog.Calls.CONTENT_URI,
            null, null, null, CallLog.Calls.DATE + " DESC");
    int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
    int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);
    int date = managedCursor.getColumnIndex(CallLog.Calls.DATE);
    int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION);
    sb.append("Call Details :");
    while (managedCursor.moveToNext()) {
        String phNumber = managedCursor.getString(number);
        String callType = managedCursor.getString(type);
        String callDate = managedCursor.getString(date);
        Date callDayTime = new Date(Long.valueOf(callDate));
        String callDuration = managedCursor.getString(duration);
        String dir = null;
        int dircode = Integer.parseInt(callType);
        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("\nPhone Number:--- " + phNumber + " \nCall Type:--- "
                + dir + " \nCall Date:--- " + callDayTime
                + " \nCall duration in sec :--- " + callDuration);
        sb.append("\n---------------------------------------------");
    }
    managedCursor.close();

    String s= sb.toString();
    String[] array;



    ArrayList&lt;String&gt; list=new ArrayList&lt;&gt;();

    for(int i=1; i&lt;40; i++){
        if(s.contains("Phone Number")){
            array=s.split("Phone Number");
           list.add(array[i - 1]);


        }
    }
</code></pre>

<p>Now i want to split all the contacts individually with particular details and display them in Listview.How can i split them and set them in custom listview. I want it to be like My operator follow ups page as shown in the link.</p>

<pre><code>  [This is how i want it to be][1]
</code></pre>