Java tutorial
//package com.java2s; import android.content.Context; import android.os.Environment; import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static String[] getExternalDirs(Context context) { List<String> paths = new ArrayList<String>(); String[] secondaryDirs = getSecondaryDirs(); if (secondaryDirs != null) { for (String secondaryDir : secondaryDirs) { paths.add(secondaryDir + "/roadsigns"); } } File externalStorageDir = Environment.getExternalStorageDirectory(); if (externalStorageDir != null && externalStorageDir.isDirectory()) { paths.add(Environment.getExternalStorageDirectory().getPath() + "/roadsigns"); } return paths.toArray(new String[paths.size()]); } public static String[] getSecondaryDirs() { List<String> ret = new ArrayList<String>(); String secondaryStorageString = System.getenv("SECONDARY_STORAGE"); if (secondaryStorageString != null && !secondaryStorageString.trim().isEmpty()) { String[] dirs = secondaryStorageString.split(":"); for (String dir : dirs) { File file = new File(dir); if (file.isDirectory() && file.canWrite()) { ret.add(dir); } } if (ret.isEmpty()) return null; else return ret.toArray(new String[ret.size()]); } else { return null; } } }