@@ -53,7 +53,7 @@ public void prepare() {
5353 int idColumn = cur .getColumnIndex (MediaStore .Audio .Media ._ID );
5454 int trackIdColumn = cur .getColumnIndex (MediaStore .Audio .Media .TRACK );
5555
56- String musicDirPath = Environment .getExternalStoragePublicDirectory (Environment .DIRECTORY_MUSIC ).getAbsolutePath ();
56+ // String musicDirPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
5757 do {
5858 String trackIdStr = cur .getString (trackIdColumn );
5959 int trackId = 0 ;
@@ -70,10 +70,11 @@ public void prepare() {
7070 mAudioPath .get (cur .getLong (idColumn )),
7171 mAlbumMap .get (cur .getLong (albumArtColumn )),
7272 trackId );
73- if (song .uri .startsWith (musicDirPath )) {
73+ // if (song.uri.startsWith(musicDirPath)) {
7474 mSongs .add (song );
75- }
75+ // }
7676 } while (cur .moveToNext ());
77+ cur .close ();
7778
7879 }
7980
@@ -84,6 +85,7 @@ private void loadAlbumArt() {
8485 null ,
8586 null );
8687
88+ assert cursor != null ;
8789 if (cursor .moveToFirst ()) {
8890 do {
8991 long id = cursor .getLong (cursor .getColumnIndex (MediaStore .Audio .Albums ._ID ));
@@ -101,6 +103,7 @@ private void loadAudioPath() {
101103 null ,
102104 null );
103105
106+ assert cursor != null ;
104107 if (cursor .moveToFirst ()) {
105108 do {
106109 long id = cursor .getLong (cursor .getColumnIndex (MediaStore .Audio .Media ._ID ));
@@ -195,6 +198,7 @@ public String getURI() {
195198
196199 Cursor mediaCursor = getContentResolver ().query (mediaContentUri , projection , selection , selectionArgs , null );
197200
201+ assert mediaCursor != null ;
198202 if (mediaCursor .getCount () >= 0 ) {
199203 mediaCursor .moveToPosition (0 );
200204// String title = mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
@@ -224,6 +228,7 @@ public String getAlbumArt() {
224228 new String [] {String .valueOf (albumId )},
225229 null );
226230
231+ assert cursor != null ;
227232 if (cursor .moveToFirst ()) {
228233 path = cursor .getString (cursor .getColumnIndex (MediaStore .Audio .Albums .ALBUM_ART ));
229234 // do whatever you need to do
0 commit comments