Xiaomi smartphones are known for their optimized memory management system, but sometimes automatic cleaning removes important files or cache of the desired applications. If you notice that after cleaning photos, documents or application data disappear, then it’s time to set up exceptions. In this article, we will discuss how to protect files from deletion on Redmi, POCO and Mi devices with a MIUI shell.
The problem is that by default, the system considers even useful data to be “junk”: messenger cache, downloaded maps in the navigators or temporary game files. Without the right settings, you risk losing hours of downloaded content or working documents. Fortunately, MIUI allows you to flexibly manage exceptions - you just need to know where to look.
Why Xiaomi is Deleting Files
Automatic cleaning in Xiaomi works on an algorithm that analyzes:
- 📅 Date of last use – files older than 30 days are considered unnecessary.
- 🗑️ Data type – cache, temporary files, thumbnails of images.
- 📉 Occupied space – if there is a lack of memory, the system removes everything in a row.
- ⚙️ Application settings – some programs (such as a gallery) label files as “junk».
The problem is compounded by the fact that MIUI doesn't always correctly recognize important data, such as:
- 📸 Original photos from the folder DCIM/.thumbnails (thumbnail).
- 🎮 Save games if they are stored in a cache (e.g. Genshin Impact or PUBG Mobile).
- 📄 PDF-files and documents downloaded through the browser.
- 🗺️ Offline maps Google Maps or Yandex.Navigator.
To avoid losses, you need to manually tell the system which data to not touch, and then we will look at all the ways to add exceptions, from standard MIUI tools to hidden functions.
Method 1: Exceptions to “Memory Cleanup” (standard method)
The easiest way is to use the built-in Cleanup utility (formerly Security) and it is available on all Xiaomi devices with MIUI 12 and later.
- Open the Cleanup app (icon with broomstick).
- Go to the “Deep Cleaning” tab.
- Press three points (⋮) in the upper right corner and select "Settings».
- Slip on the "Exceptions."
- Turn on the switch next to the desired apps or add folders manually through Add.
This menu can be protected:
- 📱 Applications – their cache and data will not be deleted.
- 📁 Folders – specify the path to the directory (for example, /storage/emulated/0/Download/Important).
- 🔄 Extension files – for example, all.pdf or.apk files.
Method limitation: Some system folders (e.g. Android/data) cannot be added to exceptions through this interface.
Data messengers (Telegram, WhatsApp)
Offline maps of navigators
Game savers (e.g. Genshin Impact)
Folder with important documents (Download/Work)
Streaming services cache (Netflix, YouTube)-->
Method 2: Protect folders through the “Files” (MIUI File Manager)
If the standard Cleanup doesn’t allow you to add the folder you want, use MIUI File Manager, which works even for system directories:
- Open the Files app.
- Go to the folder you want to protect (for example, Download or DCIM/Camera).
- Tap it on three points (⋮) and select "Properties».
- Activate the option “Add to cleaning exceptions”.
Advantages of this method:
- 🔒 It works for all folders, including system folders.
- 📌 You can protect the attached directories (for example, only Download/Projects, Not the entire Download folder).
- 🔄 Changes apply immediately, without rebooting.
Important: if the folder is on SD-card, it must first be connected as internal storage in the phone settings (Settings) → Warehouse → SD-map → Set it up as internal, otherwise the system won't be able to protect it.
What if the “Add to Exceptions” option is inactive?
Method 3: Using ADB for hidden exceptions
For advanced users, there is a way to add exceptions through ADB (Android Debug Bridge), which will help protect system data that cannot be selected through the standard interface.
- 🖥️ Computer with installed ADB-driver.
- 📱 Included debugging by USB on the phone (Settings) → The phone. → Version. MIUI → 7 times tap to unlock the developer menu, then Settings → Additionally. → For developers → Debugging by USB).
- 🔌 USB-Type C Cable (preferably original).
Instructions:
- Connect your phone to your PC and confirm access via USB.
- Open the command line (Windows) or terminal (macOS/Linux) and type:
adb shell pm grant com.miui.cleanmaster android.permission.WRITE_SECURE_SETTINGS
adb shell settings put global deep_clean_white_list "package:com.example.app|/storage/emulated/0/Download"Where:
- com.example.app is the application identifier (you can find out through the App Inspector or adb shell pm list packages).
- /storage/emulated/0/Download is the path to the folder.
To apply a few exceptions, list them through the vertical line (|):
adb shell settings put global deep_clean_white_list "package:com.whatsapp|package:com.google.android.apps.maps|/storage/emulated/0/DCIM/Camera"💡
Before using ADB, back up your data. Incorrect commands can disrupt the system.
Method 4: Disabling Automatic Cleaning for Individual Applications
If you don’t need to fully protect folders, but only save the data of a particular application (for example, Telegram cache or Chrome downloads), use the Battery and Performance settings:
- Go to Settings → Applications → Application Management.
- Select the app you want (such as WhatsApp).
- Put it on the Battery.
- Enable the "No Limits" option.
- Go back and select “Clean” → turn off “Car Clean”.
This will prevent:
- 🗑️ Removal of the app cache.
- ⏳ Forced stop of background activity.
- 📥 Cleaning up uploaded files (for example, media from chat rooms).
The downside of the method is that the application will consume more power, as the system will not limit its operation in the background.
Table: What can and cannot be protected from cleaning
| Type of data | Can exceptions be added to the | Method | Notes |
|---|---|---|---|
| Application cache | ✅ Yes. | “Cleaning” → “Exceptions” or App Settings | Does not work for system applications (e.g., Gallery) |
| Folders on internal memory | ✅ Yes. | “Files” → “Properties” → “Add to Exceptions” | You cannot protect root system folders (e.g. /data) |
| Data on SD-map | ⚠️ Partially. | Only if the card is connected as an internal storage | For external drives need root rights |
| System files (/data/data) | ❌ No. | Only through ADB or root | Risk of disrupting the system |
| Offline maps | ✅ Yes. | “Files” → select a folder with maps (for example, Android/data/com.google.android.apps.maps) | After updating the application, the path may change |
If your case doesn't make it to the table, try combining methods, such as protecting the saves of Genshin Impact:
- Add the Android/data/miHoYo.GenshinImpact folder to the exceptions via Files.
- Disable autoclean for the Genshin Impact app in the settings.
- Stop optimizing the battery for the game.
What to do if exceptions don’t work
Sometimes even after setting up exceptions, MIUI continues to delete files.
⚠️ Note: If you use third-party cleaners (such as CCleaner or Files by Google), they ignore settings. MIUI. Turn off auto-cleaning in these apps or remove them.
- 🔄 Reset cleaning settings: Go to Settings → Annexes → Application management → Cleanup → Warehouse → Clean the data. It will reset all the exceptions, and then you have to add them again.
- 📱 Update MIUI: In older versions (below). MIUI 12) the exception function is unstable. Update the system to Settings → The phone. → Update MIUI.
- 🔧 Manual editing of configs: For power users: in file /data/system/package_restrictions.xml You can manually write exceptions (root required).
If the problem persists, check:
- 📊 Is there enough free space on the device (less than 10% of memory causes aggressive cleaning).
- 🔋 Is the mode "Saving charge" turned on - it intensively cleanses the background processes.
- 🛠️ Are there any viruses (check through “Security» → «Scanner»).
💡
If exceptions don't work, check the third-party cleaners first, then update the MIUI. 90% of the time, the problem is solved by these actions.