Android: Alternative to the deprecated Context.MODE_WORLD_READABLE?

前端 未结 3 1717
清酒与你
清酒与你 2020-12-07 00:59

From here I know a way to write a file and be accessible to other app and other intent, but now that the Context.MODE_WORLD_READABLE is deprecated how can I safely accomplis

3条回答
  •  一个人的身影
    2020-12-07 01:31

    Save your video in your internal memory using:

    openFileOutput("test.mp4", "MODE_PRIVATE");
    

    Then do this:

    String path = context.getFilesDir().getAbsolutePath() + "/test.mp4"; // path to the root of internal memory.
    File f = new File(path);
    f.setReadable(true, false);
    Intent playIntent ....
    playIntent.setType("video/*");
    playIntent.setData(Uri.fromFile(f));
    

    Good Luck.

提交回复
热议问题