4

I know Android SDK is big mess for dual SIM support, but stock dialer shows this information on call log which SIM card ( 1 or 2) was used in a call. I guess it´s stored on call log default database and just want to know if it is possible to retrieve it as simple as possible. I don´t need to know if the SIM is the current one in use. By the way, probably the call log became3s a big mess if you change the Sim cards... but it is another subject and does not matter for me (at the moment ;-)

My questions:

1- Is it possible to get it ?

2- Is it a simple query on the file/database? I found an app which does it called 2SIMCallLogger , available on Google Play.

Does anyone guess how they did it?

Marcus Costa
  • 41
  • 1
  • 4

1 Answers1

1

I have phone with 2 SIM cards, and I got all fields from calllog, and field names. From results, field named "simid" shows which SIM card handled call.

public void editToFile(){
    File file = new File(Environment.getExternalStorageDirectory(), "fileOut.txt");
    try{
        BufferedWriter writer = new BufferedWriter(new FileWriter(file,true));
        writer.write(mEdit.getText().toString());
        writer.newLine();
        writer.flush();
        writer.close();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
}
public void getCallLogs(){
    final String[] projection = null;
    final String selection = null;
    final String[] selectionArgs = null;
    final String sortOrder = "DATE DESC";
    Cursor cursor = this.getContentResolver().query(Uri.parse("content://call_log/calls"),projection,selection,selectionArgs,sortOrder);
    int j=0;
    //mEdit is EditText
    mEdit.setText("");
    if (cursor != null) {
        int L=cursor.getColumnCount();
        for(int i=0;i<L;i++)
            mEdit.append(cursor.getColumnName(i) + "\t");
            mEdit.append("\n");
            while (cursor.moveToNext()) {
                j++;
            if(j>=5)
                break;
            for(int i=0;i<L;i++){
                String callField = cursor.getString(i);
                mEdit.append(callField + "\t");
            }
            mEdit.append("\n");
        }
    }
    editToFile();
}
  • On which device you tested it. Its not working for Micromax A110 Canvas 2. – Scorpion Apr 17 '14 at 03:19
  • I made tests on HTC Desire and one 5.8 inch Privileg with 2 SIM cards . This way I got names of fields, which I used in some applications. You can describe what exactly do not work. – Stoyan Mihaylov Apr 19 '14 at 17:03
  • I was testing my code which is same as yours and it was not getting all the call logs of 2 sim cards. I am getting only 90 records of my old card which i don't use frequently and the card from which i regularly call that card data is not being fetched using this code. – Scorpion Apr 19 '14 at 17:13
  • How we can get the number on which Callogs is received? ex. I have dual sim mobile so i want to know that +987654123 is Incoming call on SIM1 and +369258147 Missed call on SIM2? Please help me if you have solution of it – Naimish B. Makwana Dec 28 '15 at 09:29