Xiaomiโs memory cleaning utility is a useful tool to free up space and optimize device performance, but its aggressive algorithms often delete app cache, downloaded files, and even game data that users would like to save, such as cleaning up offline maps in Google Maps, saved memes in a gallery, or temporary instant messenger files, which will have to be downloaded again.
In this article, we will discuss how to add files, folders or applications to exceptions so that they do not fall under automatic cleaning. The instructions are relevant for all modern versions of MIUI (12 to 14), including Redmi models, POCO and the flagship Xiaomi 13/14 series.
Why Xiaomi Deletes โNecessaryโ Files and How It Works
The cleaning utility in MIUI works on two basic principles:
- ๐๏ธ Automatic cleaning โ starts when memory is scarce (usually when more is filled) 85-90% Deletes cache, temporary files and โjunkโ without notifying the user.
- ๐ Manual cleaning โ activated by the user through the Settings menu โ Memory or through a widget on the desktop, where you can choose what to clean (cache, downloads, duplicates, etc.).
The problem is that MIUI doesn't always correctly define "junk," for example, it might find that it's unnecessary.
- ๐ Download folder with important documents (if they have not been opened for a long time).
- ๐ฎ Game files (e.g. Genshin Impact cache or Call of Duty Mobile).
- ๐ฑ Telegram, WhatsApp cache, which will have to re-download media files.
- ๐บ๏ธ Offline maps (Google Maps, Yandex.Maps, 2GIS).
To avoid losses, you need to manually tell the system which data you can't touch, and MIUI has an exception mechanism for that, but it's hidden deep in the settings and it doesn't work in an obvious way.
Method 1: Adding exceptions through โMemory Cleanupโ (official method)
The easiest way to protect files is to use the built-in exception feature in the cleanup utility.It is available on all Xiaomi devices without root rights, but only works for individual applications, not for arbitrary files or folders.
Instructions:
- Open the Settings โ Memory.
- Slip the Clean button (or Clean depending on the MIUI version).
- In the upper right corner, press three dots (โฎ) and select Cleaning Settings.
- Go to the Exclusions section.
- Click Add Apps and tick those programs that should not be cleared (for example, Telegram, Google Maps, games).
Limitations of the method:
- โ Does not work for arbitrary files (for example, documents in the Download folder).
- โ Does not protect data within applications (e.g. game saving).
- โ Exclusion list resets after resetting settings or update MIUI.
Turn off automatic cleaning in memory settings|Make sure the app is not on the blacklist of optimization|Check the free space on the device (less than 10% can ignore exceptions)|Reboot the smartphone after the changes-->
If you need to protect specific files or folders (such as offline maps or downloads), go to the next method.
Method 2: Hidden folders and renaming (a bypass)
System system MIUI It does not clear folders whose names start with a dot (for example, by default,.my_backup). This technique is often used to protect data from automatic cleaning.
How it works:
- Open any file manager (such as embedded Files or Solid Explorer).
- Go to the folder you want to protect (for example, Download or DCIM/Camera).
- Create a new folder inside it and name it with a dot at the beginning (for example, a dot at the beginning,.keep_telegram Telegram files).
- Move important files to this folder.
Advantages of the method:
- โ It works without root rights.
- โ Protects any files, not just the app cache.
- โ Not reset after updates.
Disadvantages:
- โ ๏ธ Dot folders are not displayed in the standard Explorer (you need to enable the display of hidden files).
- โ ๏ธ Some applications (such as a gallery) may not see files in hidden folders.
๐ก
To see hidden folders in Xiaomi Explorer, open Files โ Settings โ Show hidden files.
Method 3: Using.nomedia to protect media files
If the cleaning system removes photos, videos, or music from folders (like DCIM or Pictures), you can use the.nomedia file. It tells Android that the folder does not contain media files, and the system stops scanning it (including for cleaning).
How to create.nomedia:
- Open the file manager and go to the folder with media files.
- Create a new text file and call it.nomedia (no extension!).
- Save the file and restart the device.
Important:
โ ๏ธ Note: The.nomedia file hides the contents of the folder from the gallery and music players. If you want files to be displayed in apps but not cleared by the system, use the hidden folder method instead (Method 2).
Example of structure:
/storage/emulated/0/
โโโ DCIM/
โ โโโ Camera/ # Common photos (can be cleaned)
โ โโโ.keep_photos/ #Secure folder (not cleared)
โ โโโ photo1.jpg
โ โโโ photo2.jpg
โ โโโ.nomedia # Additional protectionMethod 4: ADB-Teams for Advanced Users
If you're ready to use ADB (Android Debug Bridge), you can turn off the cleanup for specific application packages, or even completely block the cleanup utility, which requires a connection to a computer, but gives you maximum control.
Steps required:
- Enable USB debugging in the developer settings (Settings โ About Phone โ MIUI version โ tap 7 times, then go back to Additional settings โ For Developers).
- Connect your smartphone to your PC and execute the command: adb shell pm grant com.miui.cleanmaster android.permission.CLEAR_APP_CACHE (This disables cache clearing for selected applications).
- To add an app to the exceptions, use: adb shell cmd package compile -m speed -f com.example.app (replace com.example.app with a packet ID, for example, org.telegram.messenger for Telegram).
List of popular packet identifiers:
| Annex | Packet ID |
|---|---|
| Telegram | org.telegram.messenger |
| com.whatsapp | |
| Google Maps | com.google.android.apps.maps |
| Genshin Impact | com.mihoyo.GenshinImpact |
| 2GIS | ru.dublgis.dgismobile |
Warning: Incorrect use of ADB can disrupt the system.Before experimenting, back up your data.
How to find out the packet ID of any application?
What to do if exceptions donโt work
Sometimes even after adding to the exception, MIUI continues to delete files.
- ๐ Memory disadvantage: If less than 500MB is free, the system ignores exceptions.
- ๐ Resetting settings: After the update MIUI or reset the exception list is reset.
- ๐ซ Optimization blacklist: Some apps (like Facebook) may be blacklisted. โ Annexes โ Permits โ Auto-start.
- ๐ฑ Product performance: On weak smartphones (Redmi) 9A, POCO C31) Cleaning is more aggressive. Try turning off Optimization. MIUI battery-setting.
If nothing works, there are two radical options:
- Turn off automatic cleaning completely (Settings โ Memory โ Auto Cleaning โ Turn off).
- Use third-party cleaning apps (such as SD Maid or Files by Google) where you can customize the rules more accurately.
๐ก
On devices with MIUI 14 and later, exceptions work more reliably if you turn off the Deep Clean function in memory settings.
Frequent Mistakes and How to Avoid Them
Users often face typical problems when setting exceptions. Consider the most common:
โ ๏ธ Warning: If you add a folder to the exceptions, but the files are still deleted, check if it is inside another folder that is to be cleaned. /Download/MyFiles, But you don't protect the Download folder itself, the system can delete it completely.
Other mistakes:
- ๐ Wrong folder names: The.backup folder is protected, and the backup (without a dot) is not.
- ๐ Cash after update: After app updates, its cache may "fall out" of exceptions. check list after updates.
- ๐ฑ Different users: On some devices (for example, Xiaomi 13 Ultra) exceptions apply only to the main profile.
To check if the protection is working, perform the following test:
- Add the test file to the protected folder.
- Start manual cleaning (Settings โ Memory โ Clean).
- Check if the file is still in place.