Is it possible to prevent Android from creating additional folders inside /data/app/

That is, this is the folder where (user-level) apps¹ are installed. So making the whole thing recursively unwriteable will mostly likely break the apps and that's not really what I'd like. (although if you know how to do that I don't mind testing it out) But my primary reason is that I want to prevent any folders from being created there. Specifically the temporary folders that Download Manager is creating there. This is part of my quest to take control over the Download Manager. I can't replace it, so I'm trying different approaches to, well, manage the Manager.

Additional info: Device is rooted. Storage is internal. Android: v6.0.1, ROM: MIUI

¹ meaning the apps (APKs) themselves, I'm not speaking about /data/data/<package_name>/*

  • 1
    @Izzy I have access to a TouchWiz KitKat, and it's still got the APKs listed one after the other. I guess that the folders started popping up on Lollipop. – Grimoire Sep 9 '17 at 14:23
  • 1
    @Izzy Thanks for the edits! :) Added phone info – Emil Sep 9 '17 at 17:14
  • I'm sorry. I don't understand what you are trying to achieve? This might actually be an XY problem. If Download Manager is creating temporary folders then what's the issue with that? Moreover, what exactly is the issue that you thought to stop creation of new folders? – Firelord Sep 9 '17 at 19:36
  • @Firelord I'm trying to control all installations that take place on the device which are triggered via Download Manager (I mean not sure exactly about the details but it seems to go through it) So that I would be able to install only the apps that I manually download. This might not be the best approach, but the thing first creates temporary folder while it's downloading and there seems to be only one concurrent download allowed. So I thought maybe use that somehow. That is I'm trying to stop automatic updates/downloads – Emil Sep 9 '17 at 20:40
  • If you want to stop automatic updates why not you go to play store>settings>auto update apps and set it to " do not auto-update apps" this what are you asking is playing with fire. – Једноруки Крстивоје Sep 9 '17 at 20:56

The way to prevent creation of new files/folders inside a particular folder is to use the chattr +i command. Using "+i" makes it immutable, preventing changes by anyone, including su, until you do -i .

so doing: chattr +i /data/app

and then running: mkdir /data/app/blah will fail
but mkdir /data/app/com.android.vending-1/blah will work fine

| improve this answer | |
  • Good job I was just about to post this. – iBug Sep 15 '17 at 12:45
  • Thanks! ;) I think chattr is one of the lesser known/used Linux commands out there. It's the first time I ever had the need for it. – Emil Sep 15 '17 at 16:45

With chmod 744 as a root you ONLY can read/write in the folder /data/app (anyone else is readonly) but I wouldnt want to do this because apps are there located too. But you can only restrict user 1000 which is the system (i think) by doing

cd /

su 1000

chmod -wx /data/app/ -Rv (-R is recursively an -v is verbose)


| improve this answer | |
  • Well, I don't want to touch the existing folders because as you mentioned this is where the Apps are. I want to prevent creation of New folders inside /data/app folder. – Emil Sep 9 '17 at 10:50
  • 1. sorry for the late answer: you cant disallow the system anything without risking a bootloop, factory reset, etc. If you want to diable bloatware this way you could just uninstall it with pm uninstall – TheAnonDevil Sep 18 '17 at 14:03
  • Well, basically if one goes into the terminal mode with a root access, bootloop can happen ;) Removing bloatware is the least of my problems, got an automated script that does it. I'm trying to prevent Google from installing its apps like the Play Store update etc. So I thought maybe I block a folder it uses while downloading the app. I found a folders for new/updates to regular apps but it's smarter than that... – Emil Sep 18 '17 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.