Call Log Editing

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Call Log Editing

Postby Draffodx » Tue Dec 15, 2009 2:55 pm

Just wondering is it possible to edit the call log on Android?

I want to be able to add an entry to the call log via my application.

Is this possible and how?

I already have called the call log and can display it.

I have also used getContentResolver().insert(CallLog.Calls.CONTENT_URI, values); to insert values.

These values appear when I print the call log in logcat but lead to the call log on the emulator crashing.

here is my code:

Code: Select all
package cicero.org.test;

import android.app.Activity;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.CallLog;
import android.util.Log;
import android.widget.SimpleCursorAdapter;
import cicero.org.test.R;

public class test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        Uri myCall = ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, 0);

        Cursor cur = managedQuery(myCall, null, null, null, null);
       
        String[] projection = new String[] {
                CallLog.Calls.CACHED_NAME,
                CallLog.Calls.CACHED_NUMBER_LABEL,
                CallLog.Calls.DURATION
             };
       
        Uri myCalls = CallLog.Calls.CONTENT_URI;
       
        Cursor managedCursor = managedQuery(myCalls,
                projection, // Which columns to return
                null,       // Which rows to return (all rows)
                null,       // Selection arguments (none)
                // Put the results in ascending order by name
                CallLog.Calls.DATE + " ASC");
        this.addToCallLog();
        this.getColumnData(managedCursor);
    }
   
   
    private void getColumnData(Cursor cur){
        if (cur.moveToFirst()) {

            String name = "";
            String phoneNumber ="";
            String duration;
            int nameColumn = cur.getColumnIndex(CallLog.Calls.CACHED_NAME);
            int phoneColumn = cur.getColumnIndex(CallLog.Calls.CACHED_NUMBER_LABEL);
            int durationColumn = cur.getColumnIndex(CallLog.Calls.DURATION);
           
       
            do {
                // Get the field values
                name = cur.getString(nameColumn);
                phoneNumber = cur.getString(phoneColumn);
                duration = cur.getString(durationColumn);
               
               Log.i("NAMES !!!!! = ", name);
               // Log.i("Number !!!!! = ", phoneNumber);
                Log.i("duration !!!!! = ", duration);
               
               
            } while (cur.moveToNext());

        }
       
    }
   
    private void addToCallLog(){
       
       ContentValues values = new ContentValues();

       // Add Abraham Lincoln to Calls List;
       values.put(CallLog.Calls.CACHED_NAME, "Abraham Lincoln2");
       //values.put(CallLog.Calls.CACHED_NUMBER_LABEL, "0863497543");
       values.put(CallLog.Calls.DURATION, 102);

       Uri uri = getContentResolver().insert(CallLog.Calls.CONTENT_URI, values);

       
    }
   
}
   
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Postby Draffodx » Wed Dec 16, 2009 1:37 pm

It looks like its not possible to add to or edit anything in the Call Log, can anyone with more experience confirm this?
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Postby refill » Wed Jan 20, 2010 4:50 pm

hmm.. so late..



in AndroidMenifest.xml

u add next 2 lines

<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>

..
refill
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Jan 20, 2010 4:43 pm

Postby Draffodx » Thu Jan 21, 2010 11:48 am

Hi refill,

Thanks, have the call log working perfectly anyway :)
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 5 guests