How to edit already present file in SD CARD using SAF(storage access framework)?

吃可爱长大的小学妹 提交于 2020-01-01 05:59:49

问题


I have a doubt I read these tutorials just to get the clear understanding of the SAF introduced in kitkat in higher version of android How to use the new SD card access API presented for Android 5.0 (Lollipop)?

How to persist permission in android API 19 (KitKat)?

Android API below 19 equivalent for ContentResolver takePersistableUriPermission

Android Gallery on KitKat returns different Uri for Intent.ACTION_GET_CONTENT

Now i have a question when the intent is fired and i get select the sd card to get the uritree from the intent which i am getting but is the root tree I will have to iterate through the uri to get the specific file uri. Now the question is I have mp3 files in my phone and I want to edit that specific file which is selected so how can i get that selected files uri from the tree and edit it?I tried editing directly using file but it makes my mp3 file disappear and i dont want to fire SAF intent again n again so how to check is user has given permission to sd card or not? P.S. I am using jaudio tagger for editing the tags of mp3 files. THANK YOU!! I have got answers of almost everything in this question Now the issue if I am using jaudio tagger library for tagging mp3 files which takes File as a objects but android 4.4 and above wont let u modify File objects so I just want to knw the alternative how can i edit File objects in 4.4 above?


回答1:


This is how I did it, first copy the file from the sdcard to the phone memory and then do the desired changes and cut and paste the file again at its original place. Example is here where I am editing the tag of mp3 file which is in the sdcard:-

https://github.com/reyanshmishra/Rey-MusicPlayer/tree/master/app/src/main/java/com/boom/music/player/TagEditor



来源:https://stackoverflow.com/questions/37759515/how-to-edit-already-present-file-in-sd-card-using-safstorage-access-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!