Pro Android with Kotlin
Download 5.42 Mb. Pdf ko'rish
|
@de android telegram Pro Android with Kotlin Developing Modern Mobile
155
CHAPTER 8: APIs Contacts Managing and using contacts is one of the tasks a handheld device must really be good at. After all, handheld devices and especially smartphones get often used to communicating with other people, and contacts are abstracted entities representing people, groups, companies, or other “things” you use as address points for communication needs. With contacts being so important, the built-in contacts framework has become quite complex over the history of Android. Fortunately, the complexity can be reduced somewhat if we restrict ourselves to looking solely at the back-end part and omit user interface peculiarities that are described in other chapters of this book. What is left for the description of the contacts framework is the following: Looking at the internals, especially the database model used Finding out how to read contacts data Finding out how to write contacts data Calling system activities to handle single contacts Synchronizing contacts Using quick contact badges Contacts Framework Internals The basic class to communicate with the contents framework is the android.content. ContentResolver class. This makes a lot of sense, since contact data fits well into what content providers deal with. You thus often use content provider operations to handle contact data. See Chapter 6 for more information. The data model consists of three main tables: Contacts, Raw Contacts, Data. In addition, a couple of auxiliary tables for administrative tasks exist. You usually don’t have to deal with any kind of direct table access, but in case you are interested, take a look at the online contacts framework documentation and the documentation for the ContactsContract class, which extensively describes the content provider contract for the contacts. If you want to look at the contacts tables directly, using ADB for a virtual or rooted device, you can create a shell access to your device by using cd SDK_INST/platform-tools ; ./ adb root ; ./adb shell in a terminal; see Chapter 18 for more information, and from there investigate the tables as follows: cd /data find . -name 'contacts*.db' # <- this is to locate the contacts DB cd sqlite3 For example, enter .header on to switch on table header output, .tables to list all table names, and select * from raw_contacts; to list the Raw Contacts table. |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling