Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>public class Testopen extends Activity { private List&lt;String&gt; list; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); File file = new File(Environment.getExternalStorageDirectory() + File.separator + "mymusic" //folder name ); if (!file.exists()) { file.mkdirs(); } ListView lv = (ListView) findViewById(R.id.listview1); list = getSD(); lv.setAdapter((ListAdapter) new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, list)); Log.d("LOG", "FIRE !!!! " ); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Toast.makeText(Testopen.this,"clicked an item", Toast.LENGTH_LONG).show(); Intent intent = new Intent(Testopen.this, OpenFileActivity.class); startActivity(intent); } }); } //read from sdcard private List&lt;String&gt; getSD() { List&lt;String&gt; item = new ArrayList&lt;String&gt;(); File f = new File("/sdcard/download"); File[] files = f.listFiles(); for(int i = 0; i &lt; files.length; i++) { File file = files[i]; //take the file name only long size = file.length()/1024; String myfile = file.getPath().substring(file.getPath().lastIndexOf("/")+1,file.getPath().length()).toLowerCase(); //item.add(myfile); item.add(myfile+" "+"Size:"+size+" KB"); // Log.d("LOG", "fs "+file.length()); //item.add(file.length()); } return item; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload