I am using the cordova-plugin-file moveTo(dir, filename) function to move a file.
// uri = content://...
// storage_location = cordova.file.externalRootDirectory
function moveFileToStorage(uri, storage_location) {
window.resolveLocalFileSystemURL(storage_location, function (dir) {
window.resolveLocalFileSystemURL(uri, function (file) {
window.alert("here before the moveTo");
file.moveTo(dir, "example.txt")
window.alert("here after the moveTo");
});
});
}
The file.moveTo function is called, and the two "alerts" are called as well. The function is only working on certain Android emulators/devices. For example, the file is successfully being moved on a Nexus_5x emulator running android version API 25, and the Samsung Galaxy Note 2 (physical device) with Android version 4.4.2 But on other devices, like a Google Pixel (emulator) API 24, Nexus_5 (emulator) API 25, Goggle Pixel (hardware) API 23, the moveTo method is called, but the file is not moved.
Any ideas on what could be the cause of this problem? File size does not seem to be the issue, I have tested using very small text files and the results are not effected.