title: programming folder listviews
body: <p>I'm trying to get folders inside my app for my directory. I got the first part working but the image won't show up. My main goal is to access subdirectory in my folder. </p>
  
  <p>here is my Java code:</p>
  
  <pre><code>import java.io.File;
  import java.io.FileOutputStream;
  import java.util.List;
  
  import android.app.ListActivity;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  public class Create extends ListActivity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_create);
  
          //Click this it will take you back home
          Button button1 = (Button) findViewById(R.id.Home);
  
          button1.setOnClickListener(new OnClickListener(){
              public void onClick(View v) {
                   Intent i = new Intent(Create.this,  MainActivity.class);
                   startActivity(i);
                   Toast.makeText(getApplicationContext(),
                           "You are Home", Toast.LENGTH_LONG)
                   .show();
              }
          });
      }
  
  
      //given a path for a folder I want to list all subdirectories under it
      public void addUser(View view){
          String filename = "test";
          String content = "hello";
          String folername ="THE_FOLDER";
  
          FileOutputStream stream = null;
          //getFilesDir().listFiles();
          try{
              File file = new File(getFilesDir().getAbsoluteFile().toString() + "/" + folername);
              File folder = new File(getFilesDir().getAbsoluteFile().toString());
              File[] listOfFiles = folder.listFiles();
              stream = new FileOutputStream(file);
              stream = openFileOutput(filename,Context.MODE_PRIVATE);
              stream.write(content.getBytes());
              stream.close();
              for (int i = 0; i &lt; listOfFiles.length; i++) {
                  if (listOfFiles[i].isFile()) {
                      Log.d("FILE IS: ",listOfFiles[i].getName());
                  } else if (listOfFiles[i].isDirectory()) {
                      System.out.println("Directory " + listOfFiles[i].getName());
                  }
              }
          } catch(Exception e){
              e.printStackTrace();
          }
  
      }
  
  }
  </code></pre>
  
  <p>Here is my XML code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:backgroundTint="@android:color/holo_orange_light"
      android:foregroundTint="@android:color/holo_orange_light"
      android:background="#ffffff"
      android:orientation="vertical" &gt;
  
      &lt;EditText
          android:id="@+id/editText1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_alignRight="@+id/deleteBtn"
          android:ems="30" &gt;
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;Button
          android:id="@+id/addBtn"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/editText1"
          android:backgroundTint="@android:color/holo_red_dark"
          android:shadowColor="#A8A8A8"
          android:onClick="addUser"
          android:text="Create" /&gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/editText1"
          android:layout_alignBottom="@+id/editText1"
          android:layout_margin="20dp"
          android:layout_marginLeft="19dp"
          android:layout_toRightOf="@+id/editText1"
          android:text="Create Boxes"
          android:textColor="#000000"
          android:textSize="16dp" /&gt;
  
      &lt;ListView 
       android:id="@android:id/list" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@+id/addBtn" 
       android:backgroundTint="@android:color/holo_green_dark" /&gt;
  
      &lt;Button
          android:id="@+id/Home"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/addBtn"
          android:layout_alignBottom="@+id/addBtn"
          android:layout_margin="10dp"
          android:layout_marginLeft="33dp"
          android:layout_toRightOf="@+id/addBtn"
          android:background="@drawable/home"
          android:textSize="18dp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>