首页 > 解决方案 > 如果音乐位于外部 SD 卡中,则 Android Q 中的 ContentValues 更新失败

问题描述

我使用下面的代码将音乐类型更改为铃声。如果Android版本低于Q,它可以工作,但在Android Q中崩溃。问题是musicFile.getAbsolutePath()外部SD卡的返回路径。如果音乐位于内部存储中,则没有问题。如果音乐在外部 SD 卡中,我如何更新 contentvalue?

ContentValues contentValues = new ContentValues();
contentValues.put("_data", musicFile.getAbsolutePath());
contentValues.put("title", title);
contentValues.put("mime_type", "audio/*");
contentValues.put("is_ringtone", true);

标签: androidexternalsd-card

解决方案


推荐阅读