First, make sure you have permission for this sysfs node (usually you do not do this if you are developing a custom application).
Secondly, I would say that usually you do not need to talk to sysfs node directly from the Android app.Below application. There are Android Framework and HAL levels that have done all the abstraction for you.
Since I'm not sure what you are going to do, here is an example that I got from Android LightsService that talks directly to sysfs node, which may be useful for you.
216 private static final String FLASHLIGHT_FILE = "/sys/class/leds/spotlight/brightness"; ... 236 try { 237 FileOutputStream fos = new FileOutputStream(FLASHLIGHT_FILE); 238 byte[] bytes = new byte[2]; 239 bytes[0] = (byte)(on ? '1' : '0'); 240 bytes[1] = '\n'; 241 fos.write(bytes); 242 fos.close(); 243 } catch (Exception e) { 244
Jun
source share