How to get dual sim number call logs in android. I followed below link to get the dual sim call logs but this method returns -1 always. 
I tried other stackoverflow not much answers for dual sim call logs which is available from api 21. 
<https://stackoverflow.com/a/23907166/6891712>

I have tried using the below method which give only the call details but not able to find that from which sim the call is dialed or received

```
private void getCalldetailsNow() {

         @SuppressLint("MissingPermission") Cursor managedCursor=c.getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, CallLog.Calls.DATE + " DESC");

        int number = 0;
        if (managedCursor != null) {
            number = managedCursor.getColumnIndex( CallLog.Calls.NUMBER );
        }
        int duration1 = managedCursor.getColumnIndex( CallLog.Calls.DURATION);
        int type1=managedCursor.getColumnIndex(CallLog.Calls.TYPE);
        int date1=managedCursor.getColumnIndex(CallLog.Calls.DATE);
        int idSimId = getSimIdColumn(managedCursor);

        if( managedCursor.moveToFirst() == true ) {
            String phNumber = managedCursor.getString(number);
            String callDuration = managedCursor.getString(duration1);

            String type=managedCursor.getString(type1);
            String date=managedCursor.getString(date1);
            String gettSimNumber=managedCursor.getString(idSimId);

            String dir = null;
            int dircode = Integer.parseInt(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;
            default: 
                dir = "MISSED";
                break;
            }       
        }

        managedCursor.close();
    }

public static int getSimIdColumn(final Cursor c) {

        for (String s : new String[] { "sim_id", "simid", "sub_id" }) {
            int id = c.getColumnIndex(s);
            if (id >= 0) {

                Log.d(" Simmmm", "sim_id column found: " + s);
                return id;
            }
        }
        Log.d(" Simmmm", "no sim_id column found");
        return -1;
    }

```