query and order last rows with sqlite in android CursorLoader -


How do I order the last lines in a cursor loader with a query? The problem is that I order (in order ordered by the timestamp) in descending order to get the last 20 rows but that means that the lines start with the oldest, then I want to put the rows in the cursor ascending order, ie.

  to select * (Timestamp DESC limit 20 by message order selection) * Timestamp ASC by command:  
<:> I like the subquery I found some solutions on the Internet using P> but I do not think how can I pass such a subquiry to the cursorloader constructor. Is there any solution to this problem or do I need to implement the query in my ContentProvider

This is my code:

  @Override Public Loader & lt; Cursor & gt; OnCreateLoader (integer id, bundle args) {CursorLoader loader = new CursorLoader (getActivity), DataProvider.CONTENT_URI_MESSAGES, Null, DataProvider.COL_CHATID + "=?", New String [] {chat_id}, DataProvider.COL_TIMESTAMP + "DESC limit 20 "); Return loader; } @Override Public Zero onLoadFinished (Loader & LT; Cursor> Loader, Cursor Data) Try {{cursorAdapter.swapCursor (Data); } Hold (NullPointerException E) {Log D. (Tags, E. mailsage ()); }} @ Override Public Wide Onloader Reset (Loader & lt; Cursor> Loader) {cursorAdapter.swapCursor (null); }  


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -