Losing contacts on a Xiaomi smartphone is one of the most frustrating situations a user can face. Unlike photos or messages, contacts often don't duplicate automatically in the cloud, and restoring them without a backup turns into a real headache. But what if you know the exact location of the file where the contact database is stored? It not only makes it easier to back up manually, but also allows you to restore data even after a setup is reset or a device breaks.
In this article, we will look at where the contact file on Xiaomi smartphones (including models on MIUI 12/13/14 and HyperOS), how to find it through the file manager or ADB, and consider alternative ways to export and import.
Where to store the contact file on Xiaomi: system paths
The Xiaomi contact file is part of the Android system database, which is managed by the com.android.providers.contacts application. Physically, the data is stored in two formats:
- ๐ SQLite database โ the main file contacts2.db, containing all contacts, groups and related data (numbers, email, addresses).
- ๐ VCard-export โ files with the.vcf extension that are created when manually exported through the contact menu.
The main way to the contact base on Xiaomi (for all versions of MIUI and HyperOS):
/data/data/com.android.providers.contacts/databases/contacts2.dbHowever, access to this folder is limited: without root rights or ADB, you canโt simply copy a file through a standard file manager.
- ๐ /sdcard/MIUI/backup/AllBackup/ โ backup MIUI (If Local Backup is enabled).
- โ๏ธ /sdcard/Download/ โ vcf files are saved when exported via the contact menu.
- ๐ฑ /sdcard/DCIM/.thumbnails/ โ Sometimes temporary contact files (such as avatars) are cached here.
โ ๏ธ Attention: Direct file editing contacts2.db Without a backup can lead to the loss of all contacts! Android system blocks access to this file while the Contacts app is running, so any manipulations require a preliminary stop of the process.
How to access a contact file without root rights
If your Xiaomi doesnโt have root access, there are three legal ways to get a contact file:
- Export via the contact menu (the easiest method):
Open the Contacts app โ press three points (โฎ) โ Select Contact Management โ Import/Export of contacts โ Export to file. Contacts.vcf file will be saved in Download folder.
- Use of ADB (without root):
Connect your phone to your PC, enable USB Debugging (Settings โ About Phone โ MIUI Version โ 7 times click on version โ Return to Additional Settings โ For Developers) and execute the command:
adb backup -f contacts.ab -apk com.android.providers.contactsThis will back up the contact database in the contacts.ab file on your computer, and you'll need additional software like Android Backup Extractor to retrieve contacts2.db from it.
- Backup through MIUI:
Go to Settings โ About Phone โ Backup and Reset โ Local Backup. Select Contacts and create a backup. The file will be saved to /MIUI/backup/AllBackup/ encrypted (.bak extension).
Check the available space on your phone (minimum 50 MB)
Enable USB debugging (if you use ADB)
Make sure your contacts are synchronized with your account MI (setting โ Accounts)
Close all apps that work with contacts (Telegram, WhatsApp, etc.)
-->
Important:.ab and.bak files cannot be opened directly, they require special tools for unpacking. If you want a database of contacts2.db, it is easier to use ADB root-rights or third-party applications like Contact Backup & Restore.
Search for contact files with root rights
If your Xiaomi has Magisk or another root-getting method installed, you can directly copy the contacts2.db file through any root-enabled file manager (such as Root Explorer or Solid Explorer).
- Open the file manager and go to /data/data/com.android.providers.contacts/databases/
- Find files: contacts2.db - the main database; contacts2.db-shm and contacts2.db-wal - auxiliary files for SQLite.
Copy all three files to a secure location (e.g., on a PC or cloud).
Critical information: All three files (contacts2.db, -shm and -wal) are required to correctly restore contacts; copying only contacts2.db can damage the base when importing.
| File. | Description | Can I copy it separately? |
|---|---|---|
| contacts2.db | Main Contact Database (SQLite) | โ No (support files required) |
| contacts2.db-shm | Shared memory to speed up work | โ No. |
| contacts2.db-wal | Write-Ahead Log for Transactions | โ No. |
| contacts.vcf | Exported contacts in vCard format | โ Yes. |
โ ๏ธ Note: When copying database files through root, be sure to stop the process com.android.providers.contacts by command: adb shell am force-stop com.android.providers.contacts Otherwise file contacts2.db It may be blocked for reading.
How to Recover Contacts from a File contacts2.db
If you have a backup of the contacts2.db file (along with -shm and -wal), you can restore contacts in two ways:
Method 1: Through root access
- Delete the current database files at /data/data/com.android.providers.contacts/databases/.
- Copy backup files (contacts2.db, -shm, -wal) to the same folder.
- Change the access rights: chmod 660 /data/data/com.android.providers.contacts/databases/contacts2.db*
- Reboot the phone.
Method 2: Through ADB (without root)
If you donโt have root rights, but you have a backup of contacts.ab (created through adb backup), restore it by the team:
adb restore contacts.abA request for recovery will appear on the phone - confirm it.
Alternative method: Convert contacts2.db c.vcf using tools such as DB Browser for SQLite (open file, export table) raw_contacts into CSV, then convert to VCF via online services).
๐ก
Before restoring contacts from the backup, check its integrity: open the file contacts2.db in any SQLite browser (such as SQLiteStudio) and make sure that the table is raw_contacts not-empty.
Frequent problems and their solutions
When working with contact files on Xiaomi, users encounter typical errors:
- ๐ "No access to the folder. /data/data/" โ Solution: Use ADB Or you get root rights. Standard file managers don't have permission to read system folders.
- ๐๏ธ "File. contacts2.db damaged" โ Solution: Restore the database from backup or export contacts to.vcf before resetting your phone.
- โ๏ธ "Contacts are not synchronized with MI Cloud" โ Solution: Check your Mi Account settings (Settings) โ Accounts. โ Mi Account โ Sync) and enable the Contact option.
- ๐ฑ "Once restored, the contacts are duplicated" โ Solution: Clear current contacts via Settings before recovery โ Annexes โ Contacts โ Warehouse โ Clear the data.
If your contacts are missing after the MIUI update, try:
- Roll back the update via Settings โ About Phone โ System Update โ Click on the MIUI logo 10 times โ Select the rollback version.
- Restore contacts from MI Cloud (if sync is enabled).
- Use data recovery applications such as Dr.Fone or EaseUS MobiSaver (only work without root on newer versions of Android).
What if the contacts2.db file is not in the folder?
Alternative methods of backup contacts
If manual work with contacts2.db files seems difficult, use alternative methods:
- โ๏ธ MI Cloud: automatically syncs contacts with Xiaomi servers. โ Accounts. โ Mi Account โ Synchronization.
- ๐ฑ Google Contacts: Add a Google account and enable sync in Settings โ Accounts. โ Google โ Synchronization of the account.
- ๐ค Third-party apps: Super Backup & Restore - saves contacts in.vcf and on Google Drive. My Contacts Backup - sends backup to email. Contacts Optimizer - cleans duplicates and creates backups.
- ๐ป PC software: programs like Mobogenie or WonderShare MobileTrans allow you to export contacts to the Internet CSV/Excel.
Cloud services (MI Cloud or Google Contacts) have the advantage of automatic synchronization, but they are not immune to accidental deletion: if you delete a contact on your phone, it will disappear from the cloud, so it is recommended to periodically create local backups in.vcf format.
๐ก
The most reliable way to back up is by combining cloud sync (MI Cloud/Google) and local export to.vcf once a month.
How to Transfer Contacts from One Xiaomi to Another
Transfer contacts between Xiaomi devices can be done in several ways:
Method 1: Through the MI Cloud
- On an old phone: Enable contact sync in MI Cloud (Settings โ Accounts โ Mi Account โ Sync).
- On a new phone: log in to the same Mi Account and wait for sync.
Method 2: Through the VCF file
- On an old phone, export contacts to.vcf (as described above).
- Move the file to a new phone (e.g., via Bluetooth, Xender, or the cloud).
- On your new phone, import the file: Contacts โ Contact Management โ Import / Export โ Import from the device.
Method 3: Through Google Account
- On an old phone, add a Google Account and sync your contacts.
- On the new phone, log in to the same Google account โ contacts will be automatically pulled up.
If you have root access on both devices, you can directly copy contacts2.db files from one phone to another, but this method is risky: differences in MIUI versions can lead to database errors.