Android examples for Android OS:Root
get Builder from /sys/block/ folder
import java.io.BufferedReader; import java.io.FileReader; import java.io.Reader; public class Main { public static String getBuilder() { String str = null;/*from w w w . jav a2 s . co m*/ String sd_name = null; Object localOb; try { localOb = new FileReader("/sys/block/mmcblk0/device/type"); localOb = new BufferedReader((Reader) localOb).readLine().toLowerCase().contentEquals("sd"); if (localOb != null) { str = "/sys/block/mmcblk0/device/"; } } catch (Exception e) { e.getStackTrace(); } try { localOb = new FileReader("/sys/block/mmcblk1/device/type"); localOb = new BufferedReader((Reader) localOb).readLine().toLowerCase().contentEquals("sd"); if (localOb != null) { str = "/sys/block/mmcblk1/device/"; } } catch (Exception e) { e.getStackTrace(); } try { localOb = new FileReader("/sys/block/mmcblk2/device/type"); localOb = new BufferedReader((Reader) localOb).readLine().toLowerCase().contentEquals("sd"); if (localOb != null) { str = "/sys/block/mmcblk2/device/"; } } catch (Exception e) { e.getStackTrace(); } localOb = ""; try { localOb = new FileReader(str + "name"); sd_name = new BufferedReader((Reader) localOb).readLine(); } catch (Exception e) { e.printStackTrace(); } return sd_name; } }