How to add an exception to Xiaomi cleanup: protect important files from deletion

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.

๐Ÿ“Š What version? MIUI You're using it?
MIUI 12
MIUI 13
MIUI 14
I don't know.
other

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:

  1. Open the Settings โ†’ Memory.
  2. Slip the Clean button (or Clean depending on the MIUI version).
  3. In the upper right corner, press three dots (โ‹ฎ) and select Cleaning Settings.
  4. Go to the Exclusions section.
  5. 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:

  1. Open any file manager (such as embedded Files or Solid Explorer).
  2. Go to the folder you want to protect (for example, Download or DCIM/Camera).
  3. 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).
  4. 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:

  1. Open the file manager and go to the folder with media files.
  2. Create a new text file and call it.nomedia (no extension!).
  3. 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 protection

Method 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:

  1. Enable USB debugging in the developer settings (Settings โ†’ About Phone โ†’ MIUI version โ€“ tap 7 times, then go back to Additional settings โ†’ For Developers).
  2. 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).
  3. 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:

AnnexPacket ID
Telegramorg.telegram.messenger
WhatsAppcom.whatsapp
Google Mapscom.google.android.apps.maps
Genshin Impactcom.mihoyo.GenshinImpact
2GISru.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?
Open Google Play, find an app, and copy the link. The packet ID is the part of the URL after id=. For example, for Telegram, the link would look like this: https://play.google.com/store/apps/details?id=org.telegram.messenger, where org.telegram.messenger is the desired identifier.

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:

  1. Turn off automatic cleaning completely (Settings โ†’ Memory โ†’ Auto Cleaning โ†’ Turn off).
  2. 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:

  1. Add the test file to the protected folder.
  2. Start manual cleaning (Settings โ†’ Memory โ†’ Clean).
  3. Check if the file is still in place.

FAQ: Answers to Frequent Questions

Can I add system applications (e.g. Gallery or Music) to the exceptions?
No, Xiaomi system applications cannot be added to exceptions through standard settings. Their cache is forced to be cleared. To protect media files, use the method with hidden folders (.nomedia) or transfer files to the file. SD-card (if supported).
Why did all the exceptions drop after the MIUI update?
This is a well-known MIUI problem. Large updates (like version 13 to version 14) reset many user settings, including the exception list. We recommend after the update: Check Settings โ†’ Memory โ†’ Cleanup Settings โ†’ Exceptions. Add the right apps again. Reboot the device.
How to protect game saves (e.g. Genshin Impact or PUBG)?
Most games are stored in a folder. /Android/data/ or /Android/obb/. To protect them: Use the method 4 (ADB) To add the game to packet ID exceptions. Back up your saves through Google Play Games or manually copy the folder to your PC. For Genshin Impact, move the com.mihoyo.GenshinImpact folder to a secure location (e.g., to a secure location). SD-Please note: some games (e.g., maps, PUBG Mobile encrypts saves and transferring them can lead to data loss.
Will the folder be cleaned on SD-map?
No, cleaning utility. MIUI By default, you do not touch files on SD-But if SD-The card is formatted as an internal memory (Adoptable Storage function), it is considered as part of the main storage and can be cleaned. SD-For security, create a map. SD-card-folder (e.g. hidden file,.my_backup) And keep important data there.
How do you turn off the cleanup altogether?
There are two ways to completely disable automatic cleaning: via settings: Settings โ†’ Memory โ†’ Auto Clean โ†’ Turn off. Through ADB: Follow the command: adb shell pm uninstall -k --user 0 com.miui.cleanmaster (this will disable the cleaning utility, but may disrupt some of the MIUI's features).