0

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?

Hakim
  • 3,225
  • 5
  • 37
  • 75
  • 1
    Use join as explained here http://stackoverflow.com/questions/14090695/how-to-use-join-query-in-cursorloader-when-its-constructor-does-not-support-it – eduyayo Nov 15 '14 at 15:51
  • Thanks @eduyayo that's exactly what I'm searching for, but I need a code to copy from it? I can't find out how a `column` from `tableB` is added to `tableA`'s `ContentProvider`. – Hakim Nov 15 '14 at 20:18
  • 1
    Well, a content provider is just kind of the interface but within the implementation, instead of just queriying one single table you have to sql join both. There's no hidden secret to that! – eduyayo Nov 16 '14 at 03:20

1 Answers1

0

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.

Community
  • 1
  • 1
Hakim
  • 3,225
  • 5
  • 37
  • 75