External To Internal memory and vice-versa file tr

2019-08-29 06:13发布

问题:

I am trying to copy/move file from one location to another location, renaming file and deleting original file but its getting error like file not found exception (/storage/sdcard1/Video/hffg.mp4: open failed: EACCES (Permission denied))

In Manifest permission already given:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Problem is to transfer file from ("/storage/emulated/0/video/hffg-v-5398.mp4") location to ("/storage/sdcard1/Video/hffg.mp4") with renaming file by removing ("-v-5398")

The above problem occur only while I'm trying to copy/move file from internal memory to external memory.

I'm referring the SO How to programmatically move, copy and delete files and directories on SD?

The Answer is working perfect while file transfer perform between internal memory but throwing error on internal to external file transfer process.

I am also performing file Renaming before copy/move file.

  1. how can I transfer File from Internal to external storage ?
  2. how to remove/delete file from external storage ?
  3. is it possible to execute above both task with predefined path stored in database ? (i.e: "/storage/sdcard1/Video/hffg.mp4")