Listview is not showing the sd card data on options menu item click

151 views Asked by At

On options menu Item click I want to show the files of emulator sd card in a list view.But Its not working for me.

my code is showing nothing on the options menu item click.

here is my code which I want to execute on options menu item click

Help is always appreciated.Thanks

             private void initUI() {
 ArrayList<String> files = new ArrayList<String>();
    mFileList = (ListView) findViewById(R.id.fileList);
    try {
                object = (ArrayList<FileMetaData>) reviewer
                .review("/mnt/sdcard/");
              for (FileMetaData s : object) {

                s.getName();
            System.out.println(s.getName());

              files.add(s.getName());
            adapter = new ArrayAdapter<String>(this, R.layout.fileorfolder,
                    files);
            mFileList.setAdapter(adapter);

        }   


    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
            }
1

There are 1 answers

0
Rick Falck On

Try this:

File path = Environment.getExternalStoragePublicDirectory();
String[] files = path.list();

You now have a String array of the files and subdirectories.