开发者

how to show android file browser in windows platform

I want to show file list in android in windows platform. I used the method :

 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();

             }
      }

But It doesn't work . If I change to "BrowseTo(new File("/"))" ,it work.

thanks for help


Android is a Linux-based OS.

You should use Linux-style paths to files


Try with Environment.getRootDirectory() instead of "/"

Thanks Deepak

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜