Many users are faced with the need to manually manage their contact database. The reasons may be different: from the desire to make a full backup before flashing the device to attempts to restore deleted numbers after a system failure. The question often arises, where exactly is the file with your address book physically located in the depths of the file system Android.
The answer is not as obvious as it might seem at first glance. Unlike photos or downloads, which are stored in open directories, the contact database is protected by the system. By default, only the superuser or system processes have access to this folder. A regular file manager launched without root accesssimply will not see this directory.
In this article we will analyze in detail the data storage structure, paths to configuration files and methods for securely retrieving information. You will learn how to access hidden sections and what to do if standard synchronization methods with Google did not work.
Standard path to the contacts database
In the classic architecture Android all user application data is stored in a private section. Contacts are no exception. The main file containing all information about subscribers is usually located in the following path:
/data/data/com.android.providers.contacts/databases/
Inside this directory you will find a file named contacts2.db. This file is a SQLite database in which names, phone numbers, email addresses and account links are stored in a structured manner. However, simply copying this file through Explorer will not work. System security restrictions
System security restrictions SELinux Linux permissions block normal applications from reading this folder. Even if you connect your phone to your computer in MTP mode, the folder /data/ will be hidden. To access it, you must have superuser rights or use the debug bridge ADB.
โ ๏ธ Attention: Directly deleting or editing the file
contacts2.dbwithout creating a backup copy can lead to complete loss of the address book and incorrect operation of the Phone application. Proceed with extreme caution.
Before any manipulations with system files, be sure to make a full backup of the data partition via custom recovery (TWRP), if installed.
Accessing files via ADB and root access
If your device is rooted, the task is greatly simplified. You can use any advanced file manager, for example Root Explorer or Solid Explorer, giving them superuser rights. After this, navigation to the folder /data/data/ will become available.
If you do not have root access, the only legal way to access is to use the tool Android Debug Bridge. You will need to enable USB debugging in the developer menu and connect your smartphone to your PC. Next, a series of commands are executed to extract the database into internal memory, from where it can be copied.
The process is as follows. First you need to get read permissions in the device shell, and then copy the file to an accessible directory, for example, to the root of the SD card: After executing these commands, the file will appear on your computer. It can be opened with any SQLite app such as
adb shellsu
cp /data/data/com.android.providers.contacts/databases/contacts2.db /sdcard/
exit
adb pull /sdcard/contacts2.db
After running these commands the file contacts2.db will appear on your computer. It can be opened using any SQLite app such as DB Browser for SQLiteto view the contents of tables or export data to CSV.
โ๏ธ Preparing to extract contacts
Alternative storage locations and caches
It is worth noting that in modern versions Android (starting from 10 and higher), the data storage structure may become more complicated due to the introduction of encryption mechanisms and profile separation. Sometimes data can be duplicated or stored in specific cache directories.
In addition to the main database, it is worth checking the folders associated with account synchronization. If you use multiple accounts (Google, Samsung Account, Mi Cloud, SIM card), the data may be distributed across different logical tables within one file or have separate configuration files.
There are also temporary files and transaction logs, which usually have the extension -wal or -shm. They are located in the same folder as the main database file. When copying contacts2.db it is strongly recommended to copy these satellite files to ensure data integrity during recovery.
| File type | Extension | Purpose | Required for backup |
|---|---|---|---|
| Main database | .db | Storing all records | Yes |
| Transaction log | -wal | Unrecorded changes | Desirable |
| Memory index | -shm | Shared memory file | Desirable |
| Configuration | .xml | Synchronization settings | No |
Restoring contacts from a backup
The process of recovering data from a file contacts2.db is the reverse side of extracting it. If you plan to replace the current database with a saved one, you need to have superuser rights on the target device. Simply replacing a file through Explorer often results in permission errors when the system cannot read the new file.
Before replacing, it is critical to stop the process responsible for contacts. Otherwise, the system may overwrite your recovered file with old (empty) data from RAM or cache. Use the command force-stop via ADB or application settings.
The action algorithm looks like this: copy your saved file to the directory /data/data/com.android.providers.contacts/databases/, set the correct owner and group (usually this u0_a...), as well as access rights 660. After this, the device must be rebooted to apply the changes.
โ ๏ธ Attention: Incompatibility of Android versions when restoring the database can lead to a system crash. Do not try to transfer your database from Android 14 to Android 10 without first testing.
What to do if contacts are not displayed after restoration?
If you replaced the file, but the phone book is empty, check the file permissions. The command "ls -l" in the terminal will show the owner. If the owner is different from the system contact process, change it with the chown command. Also try clearing the Contacts app cache in Settings.
Synchronization and cloud alternatives
Manually copying database files is a method for advanced users and emergency situations. For everyday use, it is much more efficient and safer to use the built-in synchronization mechanisms. The ecosystem Android is tightly integrated with services Google Contacts.
When synchronization is enabled, all changes in the address book are instantly reflected in the cloud. This allows you to restore contacts on any device simply by logging into your account, without having to dig through system folders and use adb. In addition, Google saves the history of changes, allowing you to roll back the state of contacts 30 days ago.
Smartphone manufacturers also offer their own solutions. Samsung, Xiaomi, Huawei have their own cloud services, which often duplicate Google's functions. It is important to keep track of where exactly the new contact is saved: to your Google account, to your phone memory, or to your SIM card. Only contacts saved in the account are protected from loss if the device breaks down.
Synchronization with the Google cloud is the most reliable way to protect contacts, eliminating the need to manually copy system files.
Frequent errors and access problems
Users often encounter a situation where the database file found is empty or damaged. This may occur because the copy was made while there was an active data write and the transaction was not completed. Always try to make copies when the device is idle.
Another common problem is data encryption. On modern smartphones with disk encryption enabled, files in the folder /data/ may not be readable even with root privileges until the user unlocks the device by first entering a password or fingerprint after booting. Until this point, the decryption keys are not loaded into memory.
Sometimes antivirus or security systems (for example, Knox on Samsung) can block attempts of unauthorized access to the contacts provider, regarding this as a malware attack. In such cases, it may be necessary to temporarily disable protective mechanisms or use specialized backup software that has system signatures.
Is it possible to open the contacts2.db file on a computer without special apps?
No, this is a SQLite database file. Regular text editors will only show a set of incomprehensible characters. You will need a specialized viewer, such as DB Browser for SQLite or a browser extension.
Where are the contacts saved on the SIM card stored?
Contacts on the SIM card are not stored in the same form in the contacts2.db file. They are read through a separate provider com.android.providers.telephony and are physically located on the SIM card chip. They can be exported to your phone through the settings of the Contacts application.
Why did contacts disappear after resetting the settings, although I copied the folder?
You probably copied the file, but did not restore access rights (owner/group) or did not synchronize transaction logs (.wal). It is also possible that the contacts were linked to a remote Google account, and not to the local database.
Is it safe to edit contacts directly in the database?
It is risky. An error in an SQL query can damage the structure of a table. It is safer to export data to CSV, edit it in Excel and import it back through a standard application.