Android: save a file from an existing URI

后端 未结 8 984
半阙折子戏
半阙折子戏 2020-12-03 03:39

How to save a media file (say .mp3) from an existing URI, which I am getting from an Implicit Intent?

8条回答
  •  时光说笑
    2020-12-03 03:53

    1.Create a file from a URI path as:

    File from = new File(uri.toString());
    

    2.Create another File where you want the file to save as:

    File to = new File("target file path");
    

    3.Rename the file as:

    from.renameTo(to);
    

    With this the file from default path is automatically deleted and created at the new path.

提交回复
热议问题