Where are contacts stored on Android: location

Where are contacts stored on Android? It is important for every mobile device user to know the answer to this question, because their safety depends on it. If you reset the device to factory settings, and the phone book is saved on the internal storage, you risk being left without the numbers of friends and acquaintances. To avoid this situation taking you by surprise, copy and synchronize your contact database to virtual storage.

Database Analysis

The system contacts database is located in the following data folders\data\com.android.providers.contacts\databases\, regular contacts are stored in contacts2.db and personal information is stored in profile.db, but the basic structure of both databases is the same

Table structure

There are three more important tables: account, mimetype, data, raw_contacts, contacts. Other table structures are used less frequently. If you encounter problems, go to ContactsProvider to view the code.

Basic direct relationship between multiple tables

Account linked to account

The data table stores contact information. Each row stores a specific type of information for a contact (such as phone, name, email, social media account, address, etc.).

Where the data is stored in dataX (x is a number), according to the mimetype_id of this row, to match the information data type, the mimetype table stores multiple data types and _id as shown in the picture

matches the code, you can go to the source code through some of the following classes to see that mimetype and dataX are the corresponding relationships

For example:

For other classes, please refer to the following definition

[java] view plaincopy

  1. String MIMETYPE_EMAIL_V2 = Email.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/email_v2";
  2. String MIMETYPE_IM = Im.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/im";
  3. String MIMETYPE_NICKNAME = Nickname.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/nickname";
  4. String MIMETYPE_ORGANIZATION = Organization.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/organization";
  5. String MIMETYPE_PHONE_V2 = Phone.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/phone_v2";
  6. String MIMETYPE_SIP_ADDRESS = SipAddress.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/sip_address";
  7. String MIMETYPE_NAME = StructuredName.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/name";
  8. String MIMETYPE_POSTAL_ADDRESS_V2 = StructuredPostal.CONTENT_ITEM_TYPE;//»vnd.android.cursor.item/postal-address_v2″;
  9. String MIMETYPE_IDENTITY = Identity.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/identity";
  10. String MIMETYPE_PHOTO = Photo.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/photo";
  11. String MIMETYPE_GROUP_MEMBERSHIP = GroupMembership.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/group_membership";
  12. String MIMETYPE_NOTE = Note.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/note";
  13. String MIMETYPE_WEBSITE = Website.CONTENT_ITEM_TYPE;//"vnd.android.cursor.item/website";

Below are the views in the database (some co-query encapsulations), some of which have been labeled.

Above are some commonly used data tables and views. The detailed structure of the data table, as well as the data type and meaning of each field, must be checked in code.

Two main classes in ContactsProvider:

com.android.providers.contacts.ContactsDatabaseHelper

com.android.providers.contacts.ContactsProvider2

ContactsDatabaseHelper inherits from SqliteOpenHelper, this is a database creation and updating operation, this class contains detailed definitions of each table's fields and data types, and updates the database and contacts according to the version of the human part data CURD data encapsulation operator provided to the ContactsProvider2 call

ContactsProvider2 inherits from AbstractContactsProvider and is a protocol for transferring data between applications and databases. It is accessed through the Uri and defines the CURD method that applications need to use.

The process of working with data in contacts

data request

Let's take the DefaultContactBrowseListFragment in the main interface as an example, the inheritance relationship is as shown

as below:

The process for loading data from the List interface, inherited from ContactEntryListFragment, is as follows:

The CursorLoader is created and managed by the LoaderManager in the fragment. The fragment contains a ContactEntryListAdapter object. The CursorLoader parameters configuration is placed in the ContactEntryListAdapter. Once the data is loaded, the CursorLoader is called back from the fragment, and then use the ContactEntryListAdapter to manage the data update and control the UI

The adapter corresponding to the DefaultContactBrowseListFragment is DefaultContactListAdapter and the corresponding load cursor is ProfileAndContactsLoader.

Other operations

Creating, updating, and deleting contacts are typically encapsulated in the ContactSaveService class, as shown in the figure.

The ContactSaveService class inherits from IntentService and is a service for asynchronously processing contact data. Once the data operation is complete, the intent is passed when the operation is requested (the intent contains an action that requires a callback AND an action) callback to the Activity to notify the UIThread to perform a UI update

Let's take an example of creating a contact:

ContactEditorFragment.save() method

CreateSaveContactIntent() to ContactSaveService, passing the parameters needed for the callback

ContactSaveService, saveContact()

can execute an Activity callback because the base ContactsActivity Activity class associated with a contact operation in Contact implements ContactSaveService.Listener and then in onCreate ContactSaveService.registerListener(this) and then using the above code logic will eventually call

#4 Use Notepad

Another standard tool that can be found in all versions and editions of Windows. However, it is worth warning that viewing VCF using it is not very convenient. However, if nothing else is at hand, then this option will do.

1 So, look for the required file of the required format and right-click on it. Select Open with

2 Next, click Select another application

3 A window will appear in which you need to select Notepad and click OK

4 After a few seconds the file will open like this.

Of course, it’s difficult to understand anything in this form, but it’s possible. You can try changing the encoding. After this, the text will become more readable. It will become more acceptable for viewing.

Not the most convenient way, but it exists. And it was impossible not to mention him.

Sometimes the Notepad text editor fails to automatically detect the encoding when opening the VCF format. If you see the same picture as in the screenshot above, then you can click on the Format button and try changing the encoding. UTF-8 is usually suitable. But in some cases you have to choose options.

Main interface

The main interface is the PeopleActivity interface which is divided into two tabs namely DefaultContactBrowseListFragment and ContactTileListFragment which can be switched using viewpager

Where DefaultContactBrowseListFragment is a contact list page, mainly used to handle the loading display and searching for contacts in the contact list, the data loading process is described above, the list item view is ContactListItemView

ContactTileListFragment is a favorite contact and a general contact, this class directly inherits from Fragment, but the process is basically the same as before, the method is slightly different, the data is divided into favorite contacts and recent contacts Contacts, through ContactTileLoaderFactory, to provide a cursor loader to load different data

On the UI display, the adapter is used to control the display of frequent and frequent contacts, 3 lines and one line frequently

There is a contact creation button in the bottom right corner of the topmost layer of the main interface, click directly to enter the contact creation interface.

At the top there is a toolbar with a search button and a menu key.

The main interface also tracks supplier data changes

No. 3 Using the People application

This program is included in the latest versions of Windows 10. It is designed specifically for working with contacts. This means it can work with VCF type files. If you have a standard version of the system, then you don’t even need any settings. That's what's required.

1 Find the desired file on your computer, right-click on it and in the menu that appears, select Open with

2 In the next menu, simply select People

3 After a few seconds, the file will open in the application.

This is how simple and easy it is to open files of this type in the “top ten”. You don't even need to bother with various programs.

Everything the user needs is included in the operating system. However, we will consider another method.

Some users say that such files open well using the built-in Windows Contacts tool (Contacs). But it is not suitable for us, since this application does not support the Cyrillic alphabet. As a result, instead of names or Russian text, you will see hieroglyphs (krakozyabry).

Detailed interface

The AndroidL code does not have the previous contact details in the detail package, only some helper tools are left, and QuickContactActivity is used instead of ContactDetailActivity, and there are also significant changes to the user interface.
,The interface is sliding, the outer layer is the custom view: com.android.contacts.widget.MultiShrinkScroller. If you recently contacted a contact, the contact number will be listed immediately below the contact number, including calls and text messages, and then other information. If there is more than one of each type, one of them is displayed by default. It will be expanded when you click "View All". z

When entering from the contacts list it is in full screen mode, and when entering from other channels (currently known by SMS and desktop shortcuts) it is in a non-full screen state, which is controlled by MultiShrinkScroller (runEntranceAnimation)

Loading data is similar to the upload process described above.

#5 Use iCloud

This thing can only be found on computers not only running MacOS, but Windows. The iCloud program is a kind of cloud for storing files and synchronizing. However, it can also open VCF type files. You just need to know how to do it.

1 So, first go to the website and enter your Apple ID details. Then press “Enter”

2 Next, in the bottom panel, select the “Contacts” item and click on it.

3 Now click on the gear icon at the bottom of the window.

4 Then from the list in the menu, select “Import vCard” (Import vCard).

5 In Explorer, select the file with the desired name.

6 Click on the “Open” button.


After this, a list of saved contacts that were located in the file will open in a separate window

It is worth noting that with this method of opening the Cyrillic alphabet is displayed normally. There will be no problems with reading.

Edit interface

Edit Interface In ContactEditorActivity->ContactEditorFragment, the process of loading data in the interface is similar to the one described above. More complex is the user interface of the editing interface, which is a custom RawContactEditorView. And the obligatory flowchart

The fragment contains a custom RawContactEditorView view object and a RawContactDeltaList data object, after requesting Contact data from the database, the data is encapsulated in RawContactDeltaList and then RawContactDeltaList through bindeditors, editor.setState method The data is passed to the custom view, then RawContactEditorView splits the data and then passes each subview. and also passes the RawContactDeltaList and then the data update will be completed in the subview when the contact needs to be stored in the fragment. ,You can directly use RawContactDeltaList, the operation of saving contacts is similar to the data interaction process described above.

Select interface

The Pick interface is a ContactSelectionActivity which will load different fragments according to different activities including ContactPickerFragment.

PhoneNumberPickerFragment

EmailAddressPickerFragment

PostalAddressPickerFragment

JoinContactListFragment

The first 3 fragments are most often used

ContactSelectionActivity is usually started by startActivityForResult, so it needs to return a result before it finishes.

The data loading process has been skipped.

Import and export function

This function is called by the menu button on the main interface.

Import from SIM card

will call com.android.phone from Telephony. ADMList extends ADNList, is responsible for the data loading process, SimContacts is responsible for processing the user interface logic, everything is very simple.

Import from repository

Import the vcard file into ImportVCardActivity. It first gets the .vcf file into the storage space via VCardScanThread and then prompts the user to select a vcf file to import and cache the data via VCardCacheThread. Encapsulate the data types required for data import. The specific import process is done through bind VCardService. In the service, the ExecutorService (initialized as a single-threaded thread pool) is used to execute the ImportProcessor thread (implements Runable). ImportProcessor performs special parsing and importing. ImportProcessor Will be passed a NotificationImportExportListener during initialization to perform an interface callback once the import is complete.

Export to memory card

Exports contacts to a vcf file and saves them in a storage area. The export process is similar to the import process and is also done using VCardService.

Where is the best place to store contacts on Android?

A logical question that arises with such diversity: where are Android contacts stored in the phone’s memory? There is a corresponding folder in Explorer. Depending on the gadget model, it is called “contacts” or “contacts2”. But it is important to consider that if something happens to the phone’s memory or the smartphone itself, there is a risk of losing important information. Therefore, it is important to make additional backups.

Where is the trash can in an Android Samsung phone?

There are several applications that will help you save numbers from the book to the cloud. One of the most functional is “Save contacts”. For Android it is available on Google Play and can be installed for free. However, there is a limit on memory usage. There is a paid subscription, it provides more features.

In a few clicks, the numbers are moved to this application and uploaded to a text document in Excel, ODS, PDF, archive and others. Such formats are readable on all modern gadgets.

The Save Contacts program allows you to recover phone numbers from a text file. She saves the number, name, email. The software has a simple interface and nice design. The developers also took care of security, so there will be no data leakage.

On SIM card

You won't be able to fit many numbers here. Depending on how new the card is, it will contain from 20 to 200 records. But if you lose your phone, you can only restore the numbers by restoring the SIM.

On the phone

There is much more space in the internal memory. The number that fits there is at least 1000 numbers, it all depends on the amount of memory. But if the device is broken or lost, it cannot be restored.

Rating
( 2 ratings, average 4.5 out of 5 )
Did you like the article? Share with friends:
For any suggestions regarding the site: [email protected]
Для любых предложений по сайту: [email protected]