Fujitina
Fujitina

Reputation: 129

Copy file in /system folder with Runtime.getRuntime().exec

I have to copy a .mp3 file in /system/media/audio/ringtones and then set as default ringtone.
I try to copy it with:

        Runtime.getRuntime().exec("su");
        Runtime.getRuntime().exec("mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system");
        Runtime.getRuntime().exec("cp /storage/sdcard0/MyFile.mp3 /system/media/audio/ringtones/MyFile.mp3");
        Runtime.getRuntime().exec("mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system");

but nothing happen, even if i manually change permission of /system directory with root explorer ( i'm running a cyanogenmod 10.2 on galaxy s2 ) ... why?

If i try to copy in other directory ( i.e. /storage/sdcard0/folder/ ) all works fine. Some hint will be appreciated. After that, how can i set an .mp3 file located somewhere in the file system as default ringtone?

Upvotes: 0

Views: 1154

Answers (1)

Tohhier Allie
Tohhier Allie

Reputation: 73

I have had a similar issue with replacing the bootanimation.zip and this is how I fixed it. Hope it helps somebody.

Runtime.getRuntime().exec("mount -o remount,rw system /system");
Runtime.getRuntime().exec("cp /storage/emulated/0/bootanimation/bootanimation.zip /system/media/bootanimation.zip");
Runtime.getRuntime().exec("chmod 644 /system/media/bootanimation.zip");
Runtime.getRuntime().exec("mount -o remount,ro system /system");

Upvotes: 2

Related Questions