Does file truncate operation supported in Storage Access Framework (Android Lollipop API 21)? -


i need truncate file on removable sd card. can't call truncate(somesize) directly on file due storage access framework (saf) restrictions , forced use:

    parcelfiledescriptor pfd = getcontentresolver().openfiledescriptor(documentfile.geturi(), "rw");     fileoutputstream fos = new fileoutputstream(pfd.getfiledescriptor());     filechannel = fos.getchannel();     filechannel.truncate(somesize); 

as result have exception:

java.nio.channels.nonwritablechannelexception     @ java.nio.filechannelimpl.checkwritable(filechannelimpl.java:86)     @ java.nio.filechannelimpl.truncate(filechannelimpl.java:460) 

why above channel not writable if opened file descriptor in rw mode? there way truncate file under saf on lollipop!?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -