我知道如何列出文件,但
getFilesDir()
和
Environment.getExternalStorageDirectory()
都提供了内部存储列表
请帮帮我
完整代码
内部
File dir = new File(getFilesDir().getAbsolutePath());
File[] list = dir.listFiles();
String[] name = new String[list.length];
for (int i = 0; i < name.length; i++) {
name[i] = list[i].getName();
}
ListAdapter adapter = new FilesAdapter(this, android.R.layout.simple_list_item1, name);
ListView listView = (ListView) findViewById(R.id.internal_list);
listView.setAdapter(adapter);
外部
File sdcard = Environment.getExternalStorageDirectory();
File dir = new File(sdcard.getAbsolutePath());
File[] list = dir.listFiles();
String[] name = new String[list.length];
for (int i = 0; i < name.length; i++) {
name[i] = list[i].getName();
}
ListAdapter adapter = new FilesAdapter(this, android.R.layout.simple_list_item1, name);
ListView listView = (ListView) findViewById(R.id.internal_list);
listView.setAdapter(adapter);
由于