Android Action/system Path (move file)

Source: Internet
Author: User

Cause: You need to hide the phone drop-down box menu. The actual is to delete the/system/app/systemui.apk file, that can achieve the hidden effect. (Insufficient: will cause the mobile phone operating system to restart)   solutions: 1. First obtain the device file corresponding to the/system mount point 2. Re-mount it as read-write 3 with root permission. Delete/system/app/systemui.apk files with root permission   Focus: 1. Mount the/system path to read/write Mount-o remount/dev/xxx/system2. The program gets root permissions su   three main functions:1       Input: path here/system            output: path corresponding device file       Get device files      public static string Getdev (string path) 2       input:      output:      Execute command with root (verify command to execute normally)       public static Boolean Runrootcommand (String command) 3     input:      output:      Rename file      public static int Move (string sourcefile, String destfile)   One implementation: public static String Getdev (String Path) {    if (null = = path)         return null;    BufferedReader in = null;  &nbsp ; Try {        Process p = runtime.getruntime (). EXEC ("mount");        p.waitfor (); &nbsp ;       in = new BufferedReader (New InputStreamReader (P.getinputstream ()));        Strin G line = null;        when (line = In.readline ()) = null) {            if (line.contains path) {                return line;        & nbsp  }       }        return null;   } catch (IOException e) {       //TODO auto-generated catch block         e.printstacktrace ();   } catch (Interrup Tedexception e) {       //TODO auto-generated catch block         E.printstacktrace ();  & nbsp }       return null;}  public Static Boolean Runrootcommand (String command) {    process process = null;    DataOutputStream os = null;    try{        process = Runtime.getruntime (). EXEC ("su");        OS = new DataOutputStream (Process.getoutputstream ());        O S.writebytes (command+ "\ n");        os.writebytes ("exit\n");        Os.flush ();         process.waitfor ();   }catch (Exception e) {        return false;& nbsp  }finally{        try{            if (null! = OS) {    &NB Sp           os.close ();           }        &NBSP ;   if (null! = Process) {                Process.destroy ();           }       }catch (Exception e) {            E.printsta Cktrace ();      }   }    return true;}   //@return   0 Success   1 source file not saved  -2 transfer failed-3 parameter error public static int Move (string sourcefile, String Destfi Le) {    int result = 0;    if (null = = SourceFile | | null = = destfile)         Retu rn-3;    File SFile = new file (sourcefile);    if (!sfile.exists ())//source file does not exist         return-1;    String dev = Getdev ("/system");    if (null = dev) {        for (int i=0; I<dev.length (); i++)             SYSTEM.OUT.PRINTLN ("-----------" + (int) Dev.charat (i));        string[] contents = Dev.split ("");        String command = "Mount-o remount" +contents [0]+ "/system";        runrootcommand (command);        SYSTEM.OUT.PRINTLN ("---- ------"+command);   }    try{       String command = "mv" +sourcefile+ "" +destfile;        runrootcommand (command);    &N Bsp  //process move = Runtime.getruntime (). EXEC ("mv" +sourcefile+ "" +destfile+ "");   }catch (Exception e) {& nbsp       SYSTEM.OUT.PRINTLN ("------------" +e.getmessage ());        return-2;  & nbsp }    File Dfile = new file (destfile);    if (dfile.exists () &&!sfile.exists ()) {    & nbsp   result = 0;   }else{        result = -2;   }    return result;& nbsp  }  NOTE: The phone needs root

Android Action/system Path (move file)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.