How to check if two paths are in the same mount point?

I need to transfer a file from one directory to another in the Android file system. How can I programmatically check if these two paths are on the same mount point?

The reason I want to know this is because if they are, we need to copy the bits instead of File.rename (newPath) .

Examples when the paths are at different mount points:

  • The user wants to move the file from internal external storage.

  • The user wants to move the file from / sdcard / files to / sdcard / external_sd / files on samsungdevice.

+5
source share
2 answers

, Android:

  • , File.getCanonicalPath() .

  • /proc/mounts

  • , , , / .

.

+2

File.rename. , .

+5

All Articles