可以根据不同情况传入不同databaseUri例如查询音频数据MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
或者查询图片数据库MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
public Uri queryUriforAudio(String path,Uri databaseUri) {
File file = new File(path);
final String where = databaseUri + "='" + file.getAbsolutePath() + "'";
Cursor cursor = this.getContentResolver().query(databaseUri, null, where, null, null);
if (cursor == null) {
Log.d("uritest", "queryUriforAudio: uri为空 1");
return null;
}
int id = -1;
if (cursor != null) {
cursor.moveToFirst();