Jordan Fisher
Jordan Fisher

Reputation: 1

Copying files to system directory from app?

For the purposes of this, say I had an Image on my SDcard. I'm looking for a way to copy this to the System/App directory, but cannot for the life of me figure out how to reference the directory. I have got SU permissions from the app, so that isn't the problem. Does anyone know how this can be done? Or how I can reference the system directory?

Also I heard somewhere that I have to mount the System for read and write? How would I safely go about doing this?

I've tried some InputStream and OutputStream IO using "\\system\\app\\file.png" or "system/app/file.png", but non seem to work.

Thanks in advance

Upvotes: 0

Views: 140

Answers (2)

msh
msh

Reputation: 2770

Typically /system partition is mounted read-only and you need to remount it first

  mount -o remount,rw /system

I'm not sure about doing it "safely", writable /system is inherently unsafe, there is no way to do anything safely after that. But then again if you are running an application with root permissions, safety is out of question already.

Upvotes: 1

Bette Devine
Bette Devine

Reputation: 1194

You can copy a file from the specified location using Enivronment.getExternalStorageDirectory(). From this line you will get the root of the directory structure and now you can navigate to predefined path as per your wish..

e.g., File root = Environment.getExternalStorageDirectory();

also you can use IOUtils.copy(inputStream, outputStream); to copy from an inputsream (your png file) to an outputstream (where you want to save it).

Upvotes: 1

Related Questions