public class Ex04 extends ListActivity {
    /** Called when the activity is first created. */
private List<String> items=null;
private List<String> paths=null;
private String rootPath="/sdcard";
private TextView mPath;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mPath=(TextView)findViewById(R.id.text1);
        getFileDir(rootPath);
    }
    private void getFileDir(String filePath){
     mPath.setText(filePath);
     items=new ArrayList<String>();
     paths=new ArrayList<String>();
     File f=new File(filePath);
     File[] ffiles=f.listFiles();
     if(!filePath.equals(rootPath)){
     items.add("back to"+rootPath);
     paths.add(rootPath);
     items.add("back to../");
     paths.add(f.getParent());
     }
   for(int i=0;i<ffiles.length;i++) {      File file=ffiles[i];      items.add(file.getName());      paths.add(file.getPath());  } 
     ArrayAdapter<String> fileList = new ArrayAdapter<String>(this,R.layout.file_row, items); 
     setListAdapter(fileList); 
    } protected void onListItemClick(ListView l,View v,int position,long id){
     File file=new File(paths.get(position));
     if(file.canRead()){
     if(file.isDirectory()){
     getFileDir(paths.get(position));
     }
     else{
     new AlertDialog.Builder(this).setTitle("Message").setMessage("["+file.getName()+"] is File!").setPositiveButton("ok", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub

}
}).show();
     }
     }else{
     new AlertDialog.Builder(this).setTitle("Message").setMessage("权限不足").setPositiveButton("ok", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub

}
}).show();
    
     }
    
    }
}
以下是logcat报错信息