I need to replace a file in /data/data/... Is it possible with magisk? And if so, how?

I've read the developer guide multiple times, and it seems that it's possible using an overlay system - which I absolutely fail to understand.

Another way of replacing the file could theoretically be using shell during the module's installation process, but that gives me "operation not permitted" (+ it's not an "overlay" because we're directly modifying the file).

  • 1
    yes the main purpose of Magisk is to have read-write access to /data. the concept of overlay concerns /system (not /data) – alecxs Aug 17 '20 at 20:11
  • How would you replace /data/data/file.txt then? I tried creating a directory in the module's installer with the same structure as the file I am trying to replace (data/data/file.txt) and then in customize.sh created a variable REPLACE="/data/data/file.txt", but that doesn't seem to work. – Matěj Pešl Aug 17 '20 at 20:26
  • 1
    I'm not experienced in writing Magisk modules (what your actual concern is), but writing to /data is not a problem once you have root access. E.g. you can run a script on boot, or execute commands manually from commandline, or perform operations from a GUI root-enabled app and read/write/delete whatever you want in whole /data partition. systemless, overlay and bind-mount things are for read-only OS partitions i.e. /system, /vendor etc. /data has ever been writable. That's where the Android OS itself stores data. And that's where users store data. – Irfan Latif Aug 17 '20 at 21:23

Your Answer

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

Browse other questions tagged or ask your own question.