Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify the sort order for the query to a content provider

Tags:

I am trying to load all items from a Sqlite Table in Android and want to order the result.

How do I specify the order for the returned cursor?

I query the ContentProvider through a CursorLoader the following way:

new CursorLoader(context, RepresentativeEntityContentProvider.CONTENT_URI, null, null,             null, null); 
like image 765
Janusz Avatar asked Dec 29 '14 09:12

Janusz


People also ask

Which of the following is used to identify data in a content provider?

Content URIs A content URI is a URI that identifies data in a provider.

Which of the following methods is used to initialize a content provider?

onCreate() which is called to initialize the provider.

What is a content provider How do you implement a content provider?

A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network.


1 Answers

try below code change COLUMN_NAME with actual column name on which you wants to sort.

new CursorLoader(context, RepresentativeEntityContentProvider.CONTENT_URI, null, null,             null, "COLUMN_NAME ASC"); 
like image 115
Roll no1 Avatar answered Sep 22 '22 12:09

Roll no1