2011-06-21 55 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(),而不是 「/」

感謝 迪帕克

相關問題