Read:
do_exec("cat /sys/class/i2c-dev/i2c-2/device/2-0052/si1153/lux0_input"); String do_exec(String cmd) { String s = "\n"; try { Process p = Runtime.getRuntime().exec(cmd); BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream())); String line = null; while ((line = in.readLine()) != null) { s += line + "\n"; } } catch (IOException e) { // TODO Auto-generated catch blocK e.printStackTrace(); } Log.d("led",""+s); return cmd; }
Write :
String[] cmdline = { "sh", "-c", "echo 3 > /sys/class/i2c-dev/i2c-2/device/2-005a/drv260x/haptics_sensor_process" };
try {
Runtime.getRuntime().exec(cmdline);
} catch (IOException e) {
e.printStackTrace();
}