user1502224
user1502224

Reputation: 105

Retrieve call log with android sdk

I wanted to know if there was a way for an application to view the call log and save it as a file or something along those lines.

Upvotes: 0

Views: 870

Answers (2)

Pramod J George
Pramod J George

Reputation: 1723

If granted permission Android applications can access the call log. The call log is accessed like other datastores.

import android.app.Activity;
import android.os.Bundle;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.widget.TextView;
import android.database.Cursor;

public class TestingData extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TextView view = (TextView) findViewById(R.id.hello);
    String[] projection = new String[] {
            Calls.DATE
            , Calls.NUMBER
            , Calls.DURATION
    };
   Cursor mCur = managedQuery(CallLog.Calls.CONTENT_URI,
            projection, Calls.DURATION +"<?", 
                    new String[] {"60"},
                    Calls.DURATION + " ASC");
    mCur.moveToFirst();

    while (mCur.isAfterLast() == false) {
          for (int i=0; i<mCur.getColumnCount(); i++) {
              view.append("n" + mCur.getString(i));
          }
          mCur.moveToNext();
    }

}
}

Upvotes: 1

Diego Torres Milano
Diego Torres Milano

Reputation: 69198

Have you tried CallLog provider?
This can give you the information you are looking for.

Upvotes: 1

Related Questions