Я пытаюсь следующий код в Android R / 11
String[] columns = {
MediaStore.Audio.Genres._ID,
MediaStore.Audio.Genres.NAME,
};
try {
query = MediaStore.Audio.Genres._ID + " IN" +
" (SELECT " + MediaStore.Audio.Genres.Members.GENRE_ID +
" FROM audio_genres_map WHERE " + MediaStore.Audio.Genres.Members.AUDIO_ID + " IN" +
" (select _id from audio_meta where is_music != 0))";
cursor = Common.getInstance().getContentResolver()
.query(MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI,
columns, query, null, MediaStore.Audio.Genres.NAME);
} catch (SQLException e) {
query = MediaStore.Audio.Genres.Members.GENRE_ID + " IN" +
" (SELECT " + MediaStore.Audio.Genres.Members.GENRE_ID + " FROM audio_genres_map WHERE " +
MediaStore.Audio.Genres.Members.AUDIO_ID + " IN" +
"(select _id from audio_meta where is_music != 0))";
cursor = Common.getInstance().getContentResolver()
.query(MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI,
columns, query, null, MediaStore.Audio.Genres.NAME);
} catch (Exception e) {
}
mApp.getDBAccessHelper().getWritableDatabase().delete(DataBaseHelper.GENRES_TABLE,
null, null);
////Log.v(TAG, "genre size " + cursor.getCount());
if (cursor != null && cursor.moveToFirst()) {
do {
ContentValues genre = new ContentValues();
genre.put(DataBaseHelper.GENRE_ID, cursor.getString(0));
genre.put(DataBaseHelper.GENRE_NAME, cursor.getString(1));
ArrayList<Album> albums = getAlbumsForSelection(
"GENRES", cursor.getString(0));
if (albums != null && albums.size() > 0) {
genre.put(DataBaseHelper.GENRE_ALBUM_ART, otherUtils.getAlbumArtUri(albums.get(0)._Id).toString());
genre.put(DataBaseHelper.NO_OF_ALBUMS_IN_GENRE, "" + albums.size());
}
mApp.getDBAccessHelper().getWritableDatabase().insert(DataBaseHelper.GENRES_TABLE, null, genre);
} while (cursor.moveToNext());
}
этот код был working on Andorid Q and earlier
, однако он не работал в android R
это ошибка согласно crashalytics
no such table: audio_genres_map (code 1 SQLITE_ERROR): , while compiling: SELECT _id, name FROM audio_genres WHERE (genre_id IN (SELECT genre_id FROM audio_genres_map WHERE audio_id IN(select _id from audio_meta where is_music != 0))) ORDER BY name
keyboard_arrow_up
android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:184)
arrow_drop_down
android.content.ContentResolver.query (ContentResolver.java:918)
согласно
https://github.com/aosp-mirror/platform_packages_providers_mediaprovider/blob/master/src/com/android/providers/media/MediaProvider.java
должна быть таблица audio_genres_map
, в * 1019 было много изменений * но нет соответствующей документации. MediaStore
также был изменен, где мы можем найти документацию