MtpDevice.importFile and DocumentFile

156 Views Asked by At

MtpDevice.importFile(int objectHandle, String destPath) fails on 4.4 and above. Is there a way to import from an MtpDevice with the SD card write lock?

1

There are 1 best solutions below

0
On

For the time being this is what I'm doing, though I'd love to avoid the double transfer:

            // KitKat and higher require the extra step of importing to the cache then moving
            if (Util.hasKitkat())
            {
                File tmp = new File(getExternalCacheDir(), name);
                mMtpDevice.importFile(objectHandle, tmp.getPath());
                success = FileUtil.moveFile(CameraImportActivity.this, tmp, endFile);
            }
            else
            {
                success = mMtpDevice.importFile(objectHandle, endFile.getPath());
            }