Android: get the highest value in the column

I have a URL pointing to the content and I need to get the maximum value contained in one of the columns. Is there any aggregate function that will do this or do I need to do it manually?

+5
source share
2 answers

If you request an Android content provider, you can achieve this by passing MAX(COLUMN_NAME)in to the selection parameter ContentResolver.query:

getContentResolver().query(uri, projection, "MAX(COLUMN_NAME)", null, sortOrder);

Where Uri is the address of the content provider. This should return the single row with the highest value in COLUMN_NAME.

+19
source

Android SQLite, SELECT MAX(thecolumn) FROM TheTable , SQLite (, , SQL, "ite" not;-). ( android.database, , : -).

+1

All Articles