title: Cannot set System Property in Android using either Reflection or Linux command exec in Android
body: <p>I need to set and get a system property named "persist.sys.aabbcc". I was able to read / write the value using adb shell command like this:</p>
  
  <pre><code>adb shell setprop persist.sys.aabbcc 123456
  </code></pre>
  
  <p>and: </p>
  
  <pre><code>adb shell getprop persist.sys.aabbcc 
  123456
  </code></pre>
  
  <p>I also able to read this property in java Android using Reflection:</p>
  
  <pre><code>        @SuppressWarnings("rawtypes")
          Class SystemProperties = Class.forName("android.os.SystemProperties");
  
          //Parameters Types
          @SuppressWarnings("rawtypes")
          Class[] paramTypes = new Class[1];
          paramTypes[0] = String.class;
  
          Method get = SystemProperties.getMethod("get", paramTypes);
  
          //Parameters
          Object[] params = new Object[1];
          params[0] = new String("persist.sys.aabbcc");
  
          ret = (String) get.invoke(SystemProperties, params);
  </code></pre>
  
  <p>Or using Linux command exec:</p>
  
  <pre><code>            try
              {              
                  String line;
                  java.lang.Process p = Runtime.getRuntime().exec("getprop persist.sys.aabbcc");              
                  BufferedReader input = new BufferedReader(new   InputStreamReader(p.getInputStream()));
                  while ((line = input.readLine()) != null)
                 {
                      System.out.println(line);
                      Log.d("HelloDroid", line);           
                  }
                  input.close();
              }
               catch (Exception err)
              {
                  err.printStackTrace();
              }
  </code></pre>
  
  <p>However I cannot set (write) that property. My code (that seems not working) was:</p>
  
  <pre><code>    try {
  
          @SuppressWarnings("rawtypes")
          Class SystemProperties = Class.forName("android.os.SystemProperties");
  
  
          Method set1 = SystemProperties.getMethod("set", new Class[] {String.class, String.class});
          set1.invoke(SystemProperties, new Object[] {"persist.sys.aabbcc", "999999"});
  
  
    } catch( IllegalArgumentException iAE ){
        throw iAE;
    } catch( Exception e ){
        ret= "";       
    }
  </code></pre>
  
  <p>Not working also using exec:</p>
  
  <pre><code>    process = Runtime.getRuntime().exec("setprop persist.sys.aabbcc 555");
  </code></pre>
  
  <p>Please could you tell me if you are able to set a system property in Android java? Thanks.</p>