Android study note 21. Use ContentProvider for data sharing (4). ContentProvider and androidprovider of the Operating System (contact)The Android system provides a large number of contentproviders, such as contact information and multimedia information of the system. Our developed applications mainly call the query ()
/COM.ANDROID.PROVIDERS.CONTACTS/DATABASES/CONTACTS2.DB), which is a very complex table structure, There are more than 20 columns, including one named Sort_key, which is what we are looking for! As shown in the following illustration:
As you can see, this column is very humane to help us record the pinyin corresponding to the Chinese character, so that we can easily sort the contact by the value of this column.
Let's start with the implementation of
, int resource, String [] From, int[] to), the first parameter in the method is the context (this is this), the second parameter is the data that needs to be displayed (that is, the contact's list object), and the third parameter is the ID of the style that the individual data wants to display (that is, contact_item_ The ID of the view), the fourth parameter and the fifth parameter represent the corresponding relationship (all in the form of an array)
Examples of displaying contacts in different chapters, quickly sliding listview to display the first letter of a contact, and quickly searching with an alphabet are complicated to view network resources. In particular, some of them also implement the sectionindex interface, many people do not understand it very well. After research, we found that this type of example is not necessary and should not be implemented as such. Here we paste the code for ev
, conditional value string[] Array (contact_id)
Uri object is Uri.parse ("Content://com.android.contacts/data")
Loops are the same as above
The name corresponds to the type is Vnd.android.cursor.item/name
The corresponding type of telephone is VND.ANDROID.CURSOR.ITEM/PHONE_V2
Need permission, Android.permisssion.READ_CONTACTS
Invokes the Setadapter () method of the ListView object, assigning data to the view, and the parameter is a adapter object
Get adapter object with new Simpleadapter
Implement preset contacts (including names and numbers) to the mobile phone. Ensure that the contacts are read-only and cannot be deleted or edited.The code is divided into two parts:Part One inserts the preset contacts into the database;In Part Two mode, you cannot delete or edit a preset contact on the contact details and contact multi-choice interface.[Note] I
The ListView In the Android contact is unique, but the source code is relatively copied. It is not easy to extract it from the source code when we want to use it, and it is prone to errors, in the past few days, I have extracted it and written it as a simple example. I will give myself a memo, but I will share it with you. Well, let's take a look:
The first is the encapsulated PinnedHeaderListView with a h
This article describes the development of the Android API SMS SMS service processing and access to the method of contact person. Share to everyone for your reference, specific as follows:
The Android API supports the development of applications that can send and receive SMS messages. The Android emulator used in our d
From: http://blog.csdn.net/baimy1985/article/details/7820024
There is a previous article about the information on the card (Android information (MMS) (7)-SIM card text message). There is also a very important information on the SIM card, that is, the contacts on the card. I don't know if you have noticed that Android phones, especially those with carrier IDs, are slow to boot. This is irrelevant to the co
= (button) findviewbyid (R. Id. mybutton1 );/* Set onclicklistener to allow users to search for contacts when clicking the button */Mbutton01.setonclicklistener (New button. onclicklistener (){// @ OverridePublic void onclick (view V){// Todo auto-generated method stub/* Construct a URI to obtain the contact's resource location */// URI uri = URI. parse ("content: // contacts/people /");/* Use intent to retrieve contact data and return the selected v
Contacts in the Android system also provide external data through contentprovider. Here we can obtain all contacts, obtain contacts through phone numbers, add contacts, and use transactions to add Contacts.
Get all contacts
1. Contacts in the Android system provide data externally through contentprovider.
2. Database path:/data/COM. Android. providers. Contacts/d
When I use M1s, I feel that the last name of the contact in the prompt function is good. It is quite good to use. I made a simple function similar to this. The Code is as follows:
Package COM. FND. ui; import Java. util. arraylist; import Java. util. hashmap; import Java. util. list; import Java. util. map; import android. OS. bundle; import
This article describes the Android Development implementation method for removing contact call records. Share to everyone for your reference, specific as follows:
1. The source of the content provider responsible for storing call records is under the Contactsprovider project:Source path:
Com/android/providers/contacts/calllogprovider.java
The databases that ar
Now the development of the function needs to jump directly to the dial-up, contact, SMS interface and so on, looking for a lot of information, I organized a bit.
1, jump to the Dial-up interface, the code is as follows:
1) Direct dialing
Intent Intentphone = new Intent (Intent.action_call, Uri.parse ("Tel:" + phonenumber));
StartActivity (Intentphone);
2) jump to the Dial-up interface
Intent Intent = newintent (Intent.actio
Implement preset contacts (including names and numbers) to the mobile phone. Ensure that the contacts are read-only and cannot be deleted or edited.The code is divided into two parts:Part One inserts the preset contacts into the database;In Part Two mode, you cannot delete or edit a preset contact on the contact details and contact multi-choice interface.[Note] I
The previous article has implemented the relevant layout, this article then carries on the related function realizationThis article address: http://www.cnblogs.com/wuyudong/p/5951794.html, reprint please indicate the source.Read system contactsWhen the "Select Contacts" button is clicked, the contact list is displayed, and the system contacts are read in the following steps:The system
Recently need to implement a mobile phone address Book fast indexing function. Fast indexing function based on first letter of name. Below is a mobile phone contact Quick Index effect, the overall code is not difficult, pinyin conversion place slightly complex. The following source code: The source code has comments.
Here is the effect chart:
Mainactivity:
Import java.util.ArrayList;
Import java.util.Collections;
Import java.util.List;
Import
This example describes how Android gets the avatar of a contact. Share to everyone for your reference, specific as follows:
Public byte[] Getphoto (string people_id) {
string photo_id = null;
String Selection1 = contactscontract.contacts._id + "=" + people_id;
Cursor cur1 = Getcontentresolver (). Query (
ContactsContract.Contacts.CONTENT_URI, NULL, selection1, NULL, NULL);
if (Cur1.getcount () > 0)
This article describes the Android programming to read mobile phone contacts, dial-up, send SMS and long by menu operation method. Share to everyone for your reference, specific as follows:
1.Andrid Project Chart ↓ main operation diagram in red box in the file.
2. First layout code is as follows
A, main.xml program to run the main interface, mainly using ListView List control display mobile
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.