0
AssetManager  am=getAssets();

        try {
            files = am.list("music");

             Log.d("++++++++++++length++++++++++",""+files.length);
             if (files == null) {

                 // dir does not exist or is not a directory
                 Toast.makeText(getApplicationContext(), "Directory not exist", Toast.LENGTH_SHORT).show();
                } else {
                        for(String name : files){
                         Log.d("==========loop====",""+name);

This code shows a list of files present in logcat but when I add this with arraylist and set adapter for listview it shows nothing...

user3447428
  • 125
  • 4

1 Answers1

-1
       AssetManager m=getAssets();
       String files m.list(path);  


        Arraylist<yourmodelclassname> listviewadd=new Arraylist();
        if (files == null) {

                         // dir does not exist or is not a directory
         Toast.makeText(getApplicationContext(), "Directory not exist", Toast.LENGTH_SHORT).show();
          } else {
               for(String name : files){
                 listviewadd.addall(name); //it will added your adapter class and then set your listview.
         } 

   directly access assets folder in this way to use..
i used to access font.
         Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/ARIAL.TTF");
Sethu
  • 430
  • 2
  • 13
  • String array required for m.list(path)..... and if we use array for that so in for loop we have to take just string variable and it gives only single name of file in logcat but not in list view..... – user3291817 Mar 22 '14 at 11:30
  • okay cool you have to create a model class for maintain the string values and then set it to adapter.. it will bind on list. – Sethu Mar 22 '14 at 11:36