title: Sorting RecyclerView Items With A DATABASE
body: <p>I'm currently working on a music app which has a "Favorite Songs" tab.
  I'm trying to implement a tool that will allow the users to sort their favorite songs which are stored in a DATABASE using drag &amp; drop.</p>
  
  <p>I'm using <code>ItemTouchHelper</code> for that case, But none of my searches produced a solution that works with a database.</p>
  
  <p>** My list gets populated from the database **</p>
  
  <p><strong>FavoritesPresenter.class</strong></p>
  
  <pre><code>        ItemTouchHelper.SimpleCallback simpleCallback =
                  new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0) {
  
                      @Override
                      public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                          mRecyclerView.notifyItemMoved(viewHolder.getAdapterPosition(), target.getAdapterPosition());
                          return true;
                      }
  
                      @Override
                      public void onMoved(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, int fromPos, RecyclerView.ViewHolder target, int toPos, int x, int y) {
                          super.onMoved(recyclerView, viewHolder, fromPos, target, toPos, x, y);
  
                      }
  </code></pre>
  
  <p><strong>DataBase.class</strong></p>
  
  <pre><code>int updateOrder(long id, int newPos) {
      ContentValues cv = new ContentValues();
      cv.put(DataBaseOpenHelper.COLUMN_ORDER, newPos);
  
      String where = DataBaseOpenHelper.COLUMN_ID + "=?";
      String[] whereArgs = {String.valueOf(id)};
  
      return getWritable().update(DataBaseOpenHelper.TABLE_NAME_FAVORITE, cv, where, whereArgs);
  }
  </code></pre>
  
  <p>I've tried this "solution" <a href="https://stackoverflow.com/questions/38223107/store-new-position-of-recyclerview-items-in-sqlite-after-being-dragged-and-dropp">here</a>, But obviously it's not working for me. Any suggestions ?</p>