2011-06-21 36 views
0

我想在windows平台上显示android中的文件列表。 我使用的方法:如何在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(新文件(”/“))”,它工作。

感谢您的帮助

回答

1

Android是一个基于Linux的操作系统。

你应该使用Linux风格的路径,以文件

+0

是啊,我知道了,谢谢ihrupin – sudo

0

尝试用Environment.getRootDirectory(),而不是 “/”

感谢 迪帕克

相关问题