[Android] MediaDatabase: fix getPlaylists

Edward Wang git at videolan.org
Mon Dec 8 09:41:55 CET 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Mon Sep  1 01:46:17 2014 -0700| [162a56738984b3e6fd668a3a9e1a66612847afd1] | committer: Edward Wang

MediaDatabase: fix getPlaylists

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=162a56738984b3e6fd668a3a9e1a66612847afd1
---

 vlc-android/src/org/videolan/vlc/MediaDatabase.java |   18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
index 4465028..a1430a3 100644
--- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
@@ -241,23 +241,19 @@ public class MediaDatabase {
 
     /**
      * Get all playlists in the database
-     * @return
+     *
+     * @return An array of all the playlist names
      */
     public String[] getPlaylists() {
         ArrayList<String> playlists = new ArrayList<String>();
-        Cursor cursor;
-
-        cursor = mDb.query(
+        Cursor c = mDb.query(
                 PLAYLIST_TABLE_NAME,
                 new String[] { PLAYLIST_NAME },
                 null, null, null, null, null);
-        cursor.moveToFirst();
-        if (!cursor.isAfterLast()) {
-            do {
-                playlists.add(cursor.getString(10));
-            } while (cursor.moveToNext());
-        }
-        cursor.close();
+
+        while(c.moveToNext())
+            playlists.add(c.getString(c.getColumnIndex(PLAYLIST_NAME)));
+        c.close();
         return playlists.toArray(new String[playlists.size()]);
     }
 



More information about the Android mailing list