java.lang.NullPointerException:image not loading : <p>Attempt to invoke virtual method 'void android.widget.ImageView.setImageDrawable(android.graphics.drawable.Drawable)'.
 on a null object reference.
 i m getting this error please help.</p>

<pre><code> private void loadSongs() {
        Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
        String selection = MediaStore.Audio.Media.IS_MUSIC + "!=0";
        Cursor cursor = getContext().getContentResolver().query(uri, null, selection, null, null);
        if (cursor != null) {
            if (cursor.moveToFirst()) {
                do {

                    String name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
                    String artist = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));
                    String url = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));
                    String albumId = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
                    Cursor cursorm = getContext().getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
                            new String[] {MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ALBUM_ART},
                            MediaStore.Audio.Albums._ID+ "=?",
                            new String[] {String.valueOf(albumId)},
                            null);
                    assert cursorm != null;
                    if (cursorm.moveToFirst()) {
                        String path = cursorm.getString(cursorm.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART));
                        Drawable img = Drawable.createFromPath(path);
                        image = (ImageView)rootView.findViewById(R.id.albumArt);
                       // image.setImageDrawable(img);
                        image.setImageDrawable(ContextCompat.getDrawable(getActivity(),R.drawable.ed));
                    }
                    songInfo s = new songInfo(name, artist, url);
                    _songs.add(s);
                }
                while (cursor.moveToNext());
                cursor.close();
                recyclerView.getAdapter().notifyDataSetChanged();
            }
        }
    }
</code></pre>
