Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import android.preference.ListPreference; import android.preference.Preference; public class Main { public static void PopulateFSList(Preference preference, String[] List, String filesystem) { PopulateList(preference, List); ListPreference PrefList = (ListPreference) preference; if (filesystem != null) { String currentfs = GetCurrentFileSystem(filesystem); PrefList.setSummary("current filesystem: " + currentfs); PrefList.setValue(currentfs); } else { PrefList.setValue(""); } } public static void PopulateList(Preference preference, String[] List) { ListPreference PrefList = (ListPreference) preference; if (List == null) { PrefList.setEnabled(false); } else { PrefList.setEntryValues(List); PrefList.setEntries(List); PrefList.setEnabled(true); } } public static String GetCurrentFileSystem(String PartitionName) { String[] args = GetMountLine(PartitionName); if (args != null) { return args[2]; } return null; } public static String[] GetMountLine(String PartitionName) { try { BufferedReader bProcFS = new BufferedReader(new FileReader("/proc/mounts")); String readLine = null; while ((readLine = bProcFS.readLine()) != null) { String[] args = readLine.split(" "); if ((args.length > 3) && (args[1].equalsIgnoreCase("/" + PartitionName))) { return args; } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }