从文件资源管理器获取地址 Android

Get address from file explorer Android

我正在制作一个程序,要求用户找到可以存储在 sdcard 内部卡 上的文件的 phone。我知道要在 phone 中打开 默认文件资源管理器 我必须使用此代码:

 Intent intent = new Intent();
 intent.setAction(Intent.ACTION_GET_CONTENT);
 intent.setType("file/*");
 startActivity(intent);

但是,我的问题与与 File Explorer 的通信有关,我怎样才能获得用户文件的 address已选中。

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("file/*");
    startActivityForResult(intent, YOUR_REQUEST_CODE);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (resultCode == RESULT_OK) {
    switch (requestCode) {
    case YOUR_REQUEST_CODE:
      //get the uri from data's extras
      break;
    }
     //do whatever you want with uri
  } else {
    Toast.makeText(this, "Wrong result", Toast.LENGTH_SHORT).show();
  }
}