• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Update Android created playlist SQLite order

incutonez

Lurker
I have an app that reads a playlist, shows the playlist, and allows you to sort on the playlist. Now what I want to do is save this playlist back to the DB in that order. What I mean is, whenever I go into a music app, like BlackPlayer or Rocket Player, viewing the playlist would result in this sort that I applied in my app.

BlackPlayer accomplishes this with their sort by functionality, as it persists to other apps, so I'm trying to mimic this. Someone was very close to having the answer with my StackOverflow thread, but it appears these music apps do not respect the DEFAULT_SORT_ORDER... I'm assuming they respect how the data was originally inserted into the SQLite DB itself. I'm also assuming that BlackPlayer accomplishes this by overwriting the original SQLite file... or dropping it and reinserting each row.

Any help would be greatly appreciated.
 
Does BlackPlayer ect.... have a api that you can look at. Also, I would bet that they read it from a JSON file so how does you json file get sent to them
 
Does BlackPlayer ect.... have a api that you can look at. Also, I would bet that they read it from a JSON file so how does you json file get sent to them

I don't think so... I tried decompiling the APK, and I think I got some hints from it... so I tried the approach of deleting all rows in the table and reinserting, but unfortunately, the reinsert doesn't actually insert the rows... just returns 0... here's my code:

Code:
myButton.setOnClickListener(new AdapterView.OnClickListener() {
       public void onClick(View view) {
            ListView songGrid = getSongGrid();
            PlaylistSongCursor songGridAdapter = (PlaylistSongCursor) songGrid.getAdapter();
            Cursor myCursor = songGridAdapter.getCursor();
            ContentValues[] retVal = new ContentValues[myCursor.getCount()];
            ContentValues map;
            int i = 0;
            if(myCursor.moveToFirst()) {
                do {
                    map = new ContentValues();
                    DatabaseUtils.cursorRowToContentValues(myCursor, map);
                    retVal[i++] = map;
                } while(myCursor.moveToNext());
            }
            // Empties db
            getContentResolver().delete(getPlaylistUri(), null, null);
            // Logs 2 (as that's how many items are in my list)
            Log.d("BLA", String.valueOf(retVal.length));
            final int retInt = getContentResolver().bulkInsert(getPlaylistUri(), retVal);
            // Logs 0
            Log.d("DONE", String.valueOf(retInt));
        }
    });
 
Back
Top Bottom