在 Android 中打开默认文件夹路径?

Open a default folder path in Android?

问题:

感谢帮助,因为没有找到可接受的答案。

在onActivityResult中:

  @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (data == null)
            return;

        if (requestCode == viewfilerequestcode){

                Uri Fileuri = data.getData();
                String DFLocation="/mnt/sdcard/Office/";
                String FilePath="";

                if (FilePath.trim().equals(DFLocation.concat(GettheFilename(Fileuri))))
                {
                        FilePath = DFLocation.concat(GettheFilename(Fileuri));

                }
......
.......
........
}
.........
..........

}
                

意向开始:

        btnview.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                Intent fileintent;

                String[] mimestoview =
                        {"application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", // .doc & .docx };

                fileintent = new Intent(Intent.ACTION_OPEN_DOCUMENT); 

                fileintent.setType("*/*");
                fileintent.putExtra(Intent.EXTRA_MIME_TYPES, mimestoview );
                fileintent.addCategory(Intent.CATEGORY_OPENABLE);
                fileintent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
                fileintent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);

                try {
                    startActivityForResult(fileintent, viewfilerequestcode);

                  
                } catch (ActivityNotFoundException e) {
                    lbl.setText("No activity to handle picking a file. Showing alternatives.");
                }

            }

        });