Directory listing muliplechoice select list
<p>I've created an activity which will show the multiple-choice list of all the directories in my phone.
Till now, I've only managed to show the list of only parent folders.
I want when the user clicks of an item (not on the check-box), it should expand to show its sub-folders (also multiple choice list).
This is what I've made till now.</p>

<pre><code>Parent1
Parent2
Parent3
Parent4
</code></pre>

<p>I want if user selects Parent1, then it expands with sub-folder as:</p>

<pre><code>Parent1
- Sub-Folder1
- Sub-Folder2
Parent2
Parent3
Parent4
</code></pre>

<p>Below is my code till now:</p>

<pre><code>public class DirectoryListing extends Activity {

    ListView dirlv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.directorylisting);
        try {
            ArrayList&lt;String&gt; dirList = new ArrayList&lt;String&gt;(); 
            dirList = getAllDirList();
            ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                    android.R.layout.simple_list_item_multiple_choice, android.R.id.text1,
                    dirList);
            dirlv = (ListView) findViewById(R.id.lvDirList);
            dirlv.setAdapter(adapter);
            dirlv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
        } catch (Exception e) {
            Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT);
        }

    }

    private ArrayList&lt;String&gt; getAllDirList() {
        ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;();
        File home = new File("/");
        File[] files = home.listFiles();
        for (File file : files) {
            if (file.isDirectory()) {
                result.add(file.getName());
            }
        }
        return result;
    }
}
</code></pre>
