Code example for ContentResolver

Methods: insertquery

0
    } 
 
    private void insertAlbumArt(int albumId, DownloadFile downloadFile) {
        ContentResolver contentResolver = context.getContentResolver();
 
        Cursor cursor = contentResolver.query(Uri.withAppendedPath(ALBUM_ART_URI, String.valueOf(albumId)), null, null, null, null);
        if (!cursor.moveToFirst()) {
 
            // No album art found, add it. 
            File albumArtFile = FileUtil.getAlbumArtFile(context, downloadFile.getSong());
            if (albumArtFile.exists()) {
                ContentValues values = new ContentValues();
                values.put(MediaStore.Audio.AlbumColumns.ALBUM_ID, albumId);
                values.put(MediaStore.MediaColumns.DATA, albumArtFile.getPath());
                contentResolver.insert(ALBUM_ART_URI, values);
                Log.i(TAG, "Added album art: " + albumArtFile);
            } 
        } 
        cursor.close();
    } 
Experience pair programming with AI  Get Codota for Java