Search code examples
androidsortingandroid-listviewandroid-cursoradapterandroid-cursorloader

Sort a CursorLoader using column present in another table


I have:

  • Three tables: products, orders and order lines.
  • A CursorLoader and a CursorAdapter: ProductsOrderLoader and ProductsOrderAdapter.
  • ListView: a simple products listview.

For the time being, my list view shows products bought in a certain order (order lines), plus the rest of the products.

But these items are sorted by productName. What I want is to sort these products by quantity, however the quantity column belongs to another table orderLine.

Is it possible to stick to using CursorLoader and achieve the sorting of listview using a column present in another table?


Solution

  • I found an answer here: Get all the products, and putting a specific order's product first using only orderBy, without having to modify the ContentProvider.