如何使用SAF(存储访问框架)编辑SD CARD中已经存在的文件? [英] How to edit already present file in SD CARD using SAF(storage access framework)?

查看:173
本文介绍了如何使用SAF(存储访问框架)编辑SD CARD中已经存在的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑我阅读这些教程只是为了清楚了解在更高版本的android

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)?

如何在android API 19(KitKat)中持久保留权限?

低于19的Android API相当于ContentResolver takePersistableUriPermission

KitKat上的Android Gallery返回Intent.ACTION_GET_CONTENT的其他Uri

现在我有一个问题,当意图被触发时,我会选择sd卡以从我得到的意图中获取uritree,但我需要遍历uri以获取特定文件uri的是根树. . 现在的问题是我的手机中有mp3文件,我想编辑所选的特定文件,以便如何从树中获取所选文件uri并对其进行编辑?我尝试直接使用file进行编辑,但这会使我的mp3文件消失了,我不想再次激发SAF意图,所以如何检查用户是否已授予SD卡许可? P.S.我正在使用jaudio tagger编辑mp3文件的标签. 谢谢你!! 我已经获得了几乎所有关于这个问题的答案的问题现在的问题是,如果我使用jaudio tagger库来标记以File为对象的mp3文件,但是android 4.4及更高版本将不允许您修改File对象,所以我只想了解替代方法我可以在上述4.4中编辑文件对象吗?

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?

推荐答案

这就是我的做法, 首先将文件从sdcard复制到手机内存中,然后进行所需的更改,然后再次将其剪切并粘贴到其原始位置. 示例是在这里我编辑sdcard中的mp3文件的标签的地方:-

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

这篇关于如何使用SAF(存储访问框架)编辑SD CARD中已经存在的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆