如何使用文件浏览器应用程序打开文件夹

时间:2019-09-14 11:11:12

标签: java android android-intent android-10.0

将视频保存到外部存储后(文件浏览器应用> Android>数据> com.packageName>文件>电影),并且由于Intent.ACTION_MEDIA_SCANNER_SCAN_FILE不再适用于 Android Q ,我想通过打开File Explorer应用程序让用户知道视频保存在哪里,以便用户可以在那里看到他们的视频。

  private void getPath() {
        String videoFileName = "video_" + System.currentTimeMillis() + ".mp4";
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            savedVideoPath = getPackageDCIMPath(getApplicationContext(), videoFileName);
        } else {
            File storageDir = new File(
                    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
                            + "/FolderVideo");
            boolean success = true;
            if (!storageDir.exists()) {
                success = storageDir.mkdirs();
            }
            if (success) {
                File videoFile = new File(storageDir, videoFileName);
                savedVideoPath = videoFile.getAbsolutePath();
            }
        }
    }



public String getPackageDCIMPath(Context context, String fileName) {
        if (context == null) {
            return "";
        }
        String dcimPath = "";
        File filePath = (context.getExternalFilesDir(Environment.DIRECTORY_MOVIES));
        filePath = new File(filePath, fileName);
        dcimPath = filePath.getAbsolutePath();
        return dcimPath;
    }

我该怎么做?

0 个答案:

没有答案