Home > Mobile >  Is there a way to programmatically delete other app's cache folders in android 12?
Is there a way to programmatically delete other app's cache folders in android 12?

Time:08-08

Delete other app's cache folders, I was looking at other questions and it seems u can't use IPackageStatsObserver anymore, so any way to do it now?

CodePudding user response:

Short answer: (In most cases) No, It is not possible

Longer explanation: If you take a look at the security mechanisms of the android 12, you will notice that every one of the apps runs in it's own separate sandbox

Android assigns a unique ID to every app and runs it in separate processes. In terms of Linux, each running app is a unique user with access to personal space on the disk. Without necessary permission, it cannot access/interact with another user (app). This controls the access of each app and prevents any malicious app from interacting with other apps or the OS.

That sandbox wraps all of the application data and prevents other apps from reading/changing it:

The kernel enforces security between apps and the system at the process level through standard Linux facilities such as user and group IDs that are assigned to apps. By default, apps can't interact with each other and have limited access to the OS. If app A tries to do something malicious, such as read application B's data or dial the phone without permission, it's prevented from doing so because it doesn't have the appropriate default user privileges. The sandbox is simple, auditable, and based on decades-old UNIX-style user separation of processes and file permissions.

However, there are some ways to alter other application's data:

  1. if you are a developer of both of the apps you can make sure the sharedUserId is the same (making the ID the same, and both of the apps would run in the same sandbox)
  2. using a rooted device

edit: you might an even more technical explanation here :)

Cheers!

  • Related