Zardaloop
Zardaloop

Reputation: 1624

how to write a code to search through call logs' database using Android ask?

I am trying to develop an application to search through the receive calls in call log for a preset name or number. However I can't find any sources about where the call logs are actually stored? and how can I search through the call log at the background. In the other word, I don't want the user see anything on the screen or have any interaction.

All the app will do is searching some specific preset name or number which has been previously identified by the user and the app periodically search the database and find those specific names from the call log database and return the date and time of call.

Does anyone know how to search through the call-log database?

I would greatly appreciate if anyone can advice me on that.

Many thanks

Upvotes: 1

Views: 1037

Answers (1)

George Baker
George Baker

Reputation: 1207

You need to use a content provider to do this. You shouldn't try to access the data directly. The provider will give you a handle to access it much like you would a database.

For more information on those check out the Developer Site at http://developer.android.com/guide/topics/providers/content-providers.html

The one you want to use is CallLog. You can find it here

http://developer.android.com/reference/android/provider/CallLog.html

Here's an additional tutorial on using the contacts content provider. Utilizing the Call log one will be very similar. Also it will help you access the information you want to tie to the call log. In short it is very similar to accessing a database.

http://saigeethamn.blogspot.com/2011/05/contacts-api-20-and-above-android.html

Here's another from an older StackOverflow response with some sample code.

Need tutorials on Content providers in android

Hope this helps, George

Upvotes: 1

Related Questions