Xiaomi’s modern MIUI or HyperOS smartphones are complex computing systems where data management is built according to strict security rules. When a user asks where phone numbers are physically and logically stored, it’s not just about finding a folder in a file manager, but about interacting with a secure database of the Android operating system. Understanding this structure is necessary not only for advanced users, but also for those who want to protect their data from accidental loss when flashing or resetting settings.
Unlike older notebook phones, where contacts could be stored on the phone. SIM-In a map or in a simple text file, modern Android smartphones use a relational database SQLite. This means that phone numbers, names, email addresses and associated metadata are packaged into a special binary file, which is closed to the average user by default. The system isolates this data so that no application can arbitrarily alter or steal your phone book without special permission.
However, knowing the exact path to these files can be critical when recovering data after a system failure or when using ADB (Android Debug Bridge) to create a full copy of the system. In this article, we will detail the file structure, paths to system partitions, and methods for safely retrieving contact backups so you can have full control of your digital life.
Storage architecture in Android and MIUI
The fundamental principle of the Android operating system on which Xiaomi smartphones are based is the separation of access rights. All applications and system services operate in a so-called "sandbox", which means they are isolated from each other. Contacts are no exception: they belong to the system application "Contacts" and the contact provider com.android.contacts. This component is responsible for recording, reading and synchronizing all the numbers you see in the phone book.
Physically, data is written to the device’s internal memory, a hidden partition that is not displayed when the phone is connected to a computer by USB. Access to this space requires Root rights or the use of USB debugging with elevated privileges. The main database file has the.db extension and is often accompanied by.db-journal or.db-wal log files, which ensure data integrity in the event of a sudden power outage or recording process failure.
⚠️ Warning: Direct editing of the database system files without prior backup can result in the complete loss of all contacts and the inability to launch the Phone application.
Xiaomi’s storage structure also takes into account the features of the MIUI shell. The system can create additional indexes for quick search by (pinyin) or transliteration of names, which is especially important for Chinese versions of firmware, but is also used in global builds for optimization. The contact database file on Xiaomi usually weighs from a few kilobytes to a couple of megabytes, depending on the number of records saved and the presence of photos in them.
The exact system path to the contact database
For those looking for a specific address where the phone numbers on Xiaomi are located, the path is: /data/data/com.android.contacts/databases/. Inside this directory is the main file, which is most often called contacts2.db. It contains the entire table with numbers, names and anchors. However, getting there with a regular file manager, even with root rights, can be difficult because of the additional SELinux security mechanisms implemented in modern versions of Android.
An alternative path, which is sometimes found in older versions of Android or specific MIUI builds, can look like /data/user/0/com.android.contacts/databases/. The difference is multiplayer mode, where each user (or profile) is allocated their own space with an ID. In most cases, only one user with ID 0 is active on a standard smartphone, so the paths are virtually equivalent.
To see these files, you'll need a root-enabled file manager, like Root Explorer or MiXplorer. /data/data/ It's important to understand that simply copying a file is possible. contacts2.db to a computer without stopping the corresponding service may cause the copy to be damaged or not contain the latest changes, since part of the data may be in RAM or a record buffer.
☑️ File access check
Using ADB to Retrieve Contacts
The most professional and secure way to access the database of contacts on Xiaomi without obtaining root rights (in some scenarios) or to create a backup is to use the ADB (Android Debug Bridge) tool. This method allows you to interact with the file system at the shell command level. To start, you need to include “Debugging by USB” in the Settings menu → About Phone → (7 times tap according to MIUI) → Advanced settings → Debugging via USB.
Once you connect your smartphone to your computer and install the drivers, you can execute a command to retrieve the database. However, without root permissions, the pull command for the system directories will return the access error. If root permissions are obtained, the command will look like this:
adb shell
su
cp /data/data/com.android.contacts/databases/contacts2.db /sdcard/contacts_backup.db
exit
adb pull /sdcard/contacts_backup.dbThis script copies the database from a secure system partition to public memory (/sdcard/), And this approach minimizes the risk of damage to system files, because we're working with a copy. contacts_backup.db You can open it on your computer using SQLite software, such as DB Browser for SQLite to view, edit or export data in.csv or.vcf format.
What if the ADB can’t see the device?
Alternative Storage and Synchronization
Although the bulk of the data is in the system database, there are several backup and sync levels on Xiaomi that are actually copies of your phone book. MIUI. The system can automatically back up contacts in the phone memory or on the phone. SD-map /MIUI/backup/AllBackup/. These files have a specific extension and are protected by a password or binding to an account, but contain current data.
The second and most important layer is cloud sync. On Xiaomi smartphones, it can be a Google account or its own Mi Cloud. In the case of Google, data is synced to servers and can be restored on any device. Files are stored remotely, but the local cache can be located in the directory /data/data/com.google.android.syncadapters.contacts/. Using cloud services is the most reliable way to protect against data loss in the physical breakdown of the device.
The third option is SIM-Despite the archaic nature of the method, many users still store numbers there. SIM-The card is different from the Android file system, and access to it is carried out through special AT-commands or built-in phone functions. Capacity SIM-The card is limited and does not support the retention of additional fields (addresses, multiple numbers to the name), so this method is considered outdated, but sometimes the only possible one when switching from a notebook phone.
| Storage area | Path/Location | Access without Root | Risk of loss |
|---|---|---|---|
| The basic base of SQLite | /data/data/com.android.contacts/databases/ | No. | High (on discharge) |
| Local MIUI backup | /MIUI/backup/AllBackup/ | Yes. | Medium (at) |
| Google Contacts | Cloud/App Cash | Yes (via browser) | Low. |
| SIM-map | SIM chip | Yes (via menu) | Medium (physical wear and tear) |
Recovery and conversion of the database
If you successfully retrieved the file contacts2.db, You're going to have to work with this data. SQLite is not designed to be read directly by a human being. You're going to have to use specialized software to view the content. DB Browser will see a few tables: raw_contacts, data, phone_lookup. The basic information about phone numbers is usually found in the data table, where the field data1 contains the number itself, and the field mimetype_id indicates the type of data (phone, email, name).
To restore contacts on another device or after a reset, it is easiest to convert the database to a universal format vCard (.vcf). Many programs for working with SQLite have the function of export. There are also online converters, but downloading a file with personal phone numbers is strictly not recommended for privacy reasons.
The process of importing back to the Xiaomi phone through the file database is extremely complex and requires exact matching of firmware versions and table structure. It is much more efficient to import the restored.vcf file through the standard application Contacts: Settings → Import / Export contacts → Import from the file.vcf. The system itself recognizes the format and distributes the data to the appropriate fields of the database contacts2.db.
⚠️ Note: When importing contacts from third-party files, always check duplicates. MIUI It has a built-in function of combining duplicates, but it is better to manually check the critical numbers.
💡
Use the “Freeze” feature in your Google account settings before reset to prevent automatic synchronization of junk data immediately after your phone is turned on.
Access issues and permission rights
A common problem when trying to reach contacts is the “Access Denied” error. In modern versions of Android (10, 11, 12 and higher), Google has implemented Scoped Storage and tightened its /data/ partition access policy. Even having root rights does not always guarantee direct access to files of another application due to the SELinux (Security-Enhanced Linux) settings that run in Enforcing mode.
To circumvent these limitations for research purposes, some users use the shell-flagged adb backbone to run processes on behalf of the shell or root user. However, security policies have become even stricter in HyperOS (the new Xiaomi shell), and now full access often requires not just unlocking the bootloader, but also using special Magisk patches or modules that change the context of file security.
If your goal is simply to save numbers rather than learning the structure of the database, using embedded export tools will be much more efficient and safer. Settings path → About phone → Backup and Restore → Mobile device will allow you to create a full copy of the system, including contacts, without having to climb into system files. This backup file can also be found in the file system, but it will be encrypted.
💡
Direct editing of the system database contacts2.db is justified only in cases of complex data recovery, when standard backup methods do not work.