Create a file in /system directory

前端 未结 2 468
礼貌的吻别
礼貌的吻别 2021-01-26 18:01

I want to create a file in the /system directory. I think that directory is \"protected\" and the phone must be rooted to access and create to it. I used this simple code to cre

相关标签:
2条回答
  • 2021-01-26 18:15

    I can't tell how to implement the following steps but I think it's not too hard to find a solution on the net:

    • acquire root-access for your application
    • check if /system is mounted with option rw, if not, remount it so

    hint: use the "adb shell" and check if the upper steps can lead to success (su && remount -o remount,rw /system && touch /system/test)

    On some devices there's the unlucky chance that the internal memory is in protected mode (google S-ON / S-OFF). If this is the case for you it will not be that easy like I imagined. But even than it must be possible, since the market is installing files there. This would be the last hint, to look at the market source-code ;/

    0 讨论(0)
  • 2021-01-26 18:17

    You need to call following method on file object

    file.createNewFile();
    

    On executing this following error comes because of read-only directory

    11-09 19:45:15.136: E/VideoSample(4245): java.io.IOException: open failed: EROFS 
                        (Read-only file system)
    11-09 19:45:15.136: E/VideoSample(4245):    at 
                         java.io.File.createNewFile(File.java:940)
    
    0 讨论(0)
提交回复
热议问题