Академический Документы
Профессиональный Документы
Культура Документы
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
Home
About us
Contact us
Privacy Policy
Tutorials
Gadgets
Internet
Technologies
Android Call Log Example (add, update, delete entries in call log)
Here we will learn how to add / delete / update entries in Android call log example code. It is very simple to
update Android call log programmatically. Only we need a small code snippet to adding and deleting entries
into/from Android call log. We will discuss how to add/delete outgoing call, missed calls and incoming calls
into/from Android call log. To make the code very simple. I have created a java class called CallLogUtility in
which i have written 2 functions (one is for add new entries into call log and other is for delete entries from the
call log). Here is the class with the java file. Just add this file in your projejcts source code and call these
functions. Call the function AddNumToCallLog(), if you want to add entries in call log. Call
the function DeleteNumFromCallLog(), if you want to delete entries from call log.
1. CallLogUtility Class
1
2
3
4
5
6
7
8
9
import android.content.ContentResolver;
import android.content.ContentValues;
import android.net.Uri;
import android.provider.CallLog;
import android.util.Log;
http://techblogon.com/android-call-log-example-code-add-update-delete-numbers/
1/9
15/07/2015
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 }
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
while(strNum.contains("-"))
{
strNum =strNum.substring(0,strNum.indexOf('-')) + strNum.substring(strNum.indexOf
}
ContentValues values = new ContentValues();
values.put(CallLog.Calls.NUMBER, strNum);
values.put(CallLog.Calls.DATE, timeInMiliSecond);
values.put(CallLog.Calls.DURATION, 0);
values.put(CallLog.Calls.TYPE, type);
values.put(CallLog.Calls.NEW, 1);
values.put(CallLog.Calls.CACHED_NAME, "");
values.put(CallLog.Calls.CACHED_NUMBER_TYPE, 0);
values.put(CallLog.Calls.CACHED_NUMBER_LABEL, "");
Log.d("AddToCallLog", "Inserting call log placeholder for " + strNum);
if(null != resolver)
{
resolver.insert(CallLog.Calls.CONTENT_URI, values);
}
//getContentResolver().delete(url, where, selectionArgs)
Note: Add your package file on top of the code when you will use it.
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>
<uses-sdk
http://techblogon.com/android-call-log-example-code-add-update-delete-numbers/
2/9
15/07/2015
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.techblogon.updatecalllog.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</manifest>
//if you want to delete any number from call log then follow below 2 lines of code
String numberStr = "+918554887076"; // delete this number from call log
CallLogUtility utility = new CallLogUtility();
utility.DeleteNumFromCallLog(getBaseContext().getContentResolver(), numberStr)
3/9
15/07/2015
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
I hope this small tutorial on Android Call Log Example Code (add, update, delete entries from call log) will
help you at its best.
Previous Page
Android Tutorial Home Page
Next Page
C ONNECT
android add entries in call log, android delete entries from call log, update call log in android
10 Responses to Android Call Log Example Code (add, update, delete numbers
from call log)
1.
2.
3.
http://techblogon.com/android-call-log-example-code-add-update-delete-numbers/
4/9
15/07/2015
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
SmrutiRanjan says:
July 6, 2013 at 6:58 pm
Dear Shan,
What kind of apk you want to create?
Reply
4.
5.
ashok says:
July 11, 2013 at 7:26 am
hi sir
please let me know ,during aunning my app i have an error like The method getBaseContext() is
undefined for the type CallLogUtility
why its happen, i followed whatever the steps you declared above
Reply
SmrutiRanjan says:
July 12, 2013 at 7:18 pm
getBaseContext();
This is only to collect the context of your app. You can use other way like passing it from where it
called
Reply
6.
maninder says:
July 22, 2013 at 10:44 pm
Hello,
Can you please point me to any open source code/example for taking a picture with voice command in
camera? It would seem that such an app, need to filter out all noise till it hear a specific word such as
shoot? Since google servers are responsible for converting voice commands to meaningful commands,
does it mean that all sounds captured by voice recognition would be sent to google?
Reply
7.
A.N says:
http://techblogon.com/android-call-log-example-code-add-update-delete-numbers/
5/9
15/07/2015
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
Sarah says:
November 16, 2013 at 5:01 am
I believe what you posted was actually very reasonable.
However, think on this, suppose you were to
write a killer headline? I aint saying your content is not solid., but
what if you added something to maybe get a persons attention?
I mean Android Call Log Example Code (add, update, delete numbers from call log)
| Techblogon is kinda boring. You could look at Yahoos home
page and note how they create article titles to
grab viewers to open the links. You might add a related video or a related picture or two to get readers
interested
about what youve written. In my opinion,
it would bring your website a little livelier.
Reply
Leave a Reply
Your email address will not be published. Required fields are marked *
Name *
Email *
Website
six 5 =
http://techblogon.com/android-call-log-example-code-add-update-delete-numbers/
6/9
15/07/2015
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
Comment
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym
title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del
datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" dataurl=""> <span class="" title="" data-url="">
Post Comment
Search
Techblogon
Follow
+1
+ 305
Like 1,859 people like this. Be the first of your friends.
Recommend on Google
Follow @techblogon
http://techblogon.com/android-call-log-example-code-add-update-delete-numbers/
7/9
15/07/2015
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
RSS Feed
Google Plus
Archives
March 2015
July 2014
April 2014
October 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
Categories
Android
Android Tutorial
Design Patterns
Displays
E-Commerce
Gadgets
Google
Internet
Mobile Phones
Softwares
Technologies
Tutorials
Windows
Pages
About us
Contact us
Privacy Policy
http://techblogon.com/android-call-log-example-code-add-update-delete-numbers/
8/9
15/07/2015
Android Call Log Example Code (add, update, delete numbers from call log) | Techblogon
Meta
Log in
Entries RSS
Comments RSS
WordPress.org
2015 Techblogon
http://techblogon.com/android-call-log-example-code-add-update-delete-numbers/
9/9