CallLog Content Provider

Following code demonstrates retrieving information such as caller label, duration of the call using CallLog Content Provider.

Write the following code in onCreate() method.

String[] requestedColumns =
Cursor calls = managedQuery(CallLog.Calls.CONTENT_URI,
		requestedColumns, null, null, null);

Log.i(DEBUG_TAG, "Call count: " + calls.getCount());

int durIdx = calls.getColumnIndex(CallLog.Calls.DURATION);
int totalDuration = 0;
while (!calls.isAfterLast())
	Log.i(DEBUG_TAG, "Duration: " + calls.getInt(durIdx));
			totalDuration += calls.getInt(durIdx);
		"inside while " + totalDuration, 20).show();
Log.i(DEBUG_TAG, "Call Duration: " + totalDuration);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s