所以,基本上我有这个代码(所有信用到mburhman的文件资源管理器 - https://github.com/mburman/Android-File-Explore):
private File path = new File(Environment.getExternalStorageDirectory() + "");
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
loadFileList();
showDialog(DIALOG_LOAD_FILE);
Log.d(TAG, path.getAbsolutePath());
readDir = (Button) findViewById(R.id.btnReadDirectory);
readDir.setOnClickListener(this);
}
private void loadFileList() {
try {
path.mkdirs();
} catch (SecurityException e) {
Log.e(TAG, "unable to write on the sd card ");
}
if (path.exists()) {
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
// TODO Auto-generated method stub
File sel …Run Code Online (Sandbox Code Playgroud)