Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're actually more interested in learning to write your own, I'd suggest taking a good long read through the <a href="http://developer.android.com/reference/java/io/File.html" rel="noreferrer">File</a> class documentation. That's where you're going to be doing most of the work.</p> <p>In the case of SD cards/other external storage for Android, you'll want to first check to ensure that the external storage is mounted and available before trying to read it, using the <a href="http://developer.android.com/reference/android/os/Environment.html" rel="noreferrer">Environment</a> class:</p> <pre><code>String extState = Environment.getExternalStorageState(); //you may also want to add (...|| Environment.MEDIA_MOUNTED_READ_ONLY) //if you are only interested in reading the filesystem if(!extState.equals(Environment.MEDIA_MOUNTED)) { //handle error here } else { //do your file work here } </code></pre> <p>Once you've determined the proper state of the external storage, a simple way to start is to use File's listFiles() method, like so:</p> <pre><code>//there is also getRootDirectory(), getDataDirectory(), etc. in the docs File sd = Environment.getExternalStorageDirectory(); //This will return an array with all the Files (directories and files) //in the external storage folder File[] sdDirList = sd.listFiles(); </code></pre> <p>You can then start using FileFilters to narrow down your results:</p> <pre><code>FileFilter filterDirectoriesOnly = new FileFilter() { public boolean accept(File file) { return file.isDirectory(); } }; File[] sdDirectories = sd.listFiles(filterDirectoriesOnly); </code></pre> <p>From there on, just read through the docs to find the type of thing you're looking to do with it, and then you can work on tying these into list adapters, etc.</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload