我想在 Windows 平台的 android 中显示文件列表。我使用的方法:
private void browseToRoot() {
browseTo(new File("C:\\");
}
private void browseTo(final File aDirectory){
if (aDirectory.isDirectory()){
this.currentDirectory = aDirectory;
fill(aDirectory.listFiles());
}else{
OnClickListener okButtonListener = new OnClickListener(){
// @Override
public void onClick(DialogInterface arg0, int arg1) {
// Lets start an intent to View the file, that was clicked...
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("file://" + aDirectory.getAbsolutePath()));
startActivity(myIntent);
}
};
OnClickListener cancelButtonListener = new OnClickListener(){
// @Override
public void onClick(DialogInterface arg0, int arg1) {
// Do nothing
}
};
new AlertDialog.Builder(this)
.setTitle("Question")
.setMessage("Do you want to open that file?"+ aDirectory.getName())
.setPositiveButton("OK", okButtonListener)
.setNegativeButton("Cancel", cancelButtonListener)
.show();
}
}
但它不起作用。如果我更改为 "BrowseTo(new File("/"))" ,它可以工作。
感谢帮助