How to get values from database to set valies ina list view according to alpherbatical order

Ishara Asheni

This is my code so far to retrive values from database to the listview. I need to make them appear according to alphabetical order. How should I change this code? Please help!

  public List<Units> getAllUnit() {
          List<Units> unit = new ArrayList<Units>();

          SQLiteDatabase db = getWritableDatabase();
         Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_UNITS,  null);

         if (cursor.moveToFirst()) {
              do {
                unit.add(new Units(Integer.parseInt(cursor.getString(0)) , cursor.getString(1), cursor.getString(2), cursor.getString(3)));
        }
             while (cursor.moveToNext());
         }
         cursor.close();
         db.close();
         return unit;
      }
Umair

You could use your query like this:

db.rawQuery("SELECT *
        FROM " +tableName +" ORDER BY " +yourcolumnName+ " DESC", null);

hope it helps.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

how to get image from drawable according to their names in the sqlite database and then display it in list view

分類Dev

Set values of column in dataframe according to the order of another column value in python

分類Dev

How to get ranks from a sample in a list of values?

分類Dev

Pandas - Sum values in list according to index from another list

分類Dev

How to fill dropdown list options with values from database in rails?

分類Dev

how can i parse data from the url from one activity containing using a list view to another activity according to these codes?

分類Dev

get a set of values from an array

分類Dev

How to get the list of child nodes from firebase database reference?

分類Dev

c# - How to get sum of the values from List?

分類Dev

How to get a list of non duplicate values from one property

分類Dev

how to get SUM of a set of values from a table then the MAX of those values and echo the 5 highest values

分類Dev

Get all values from a list of list with jq

分類Dev

Android: How to maintain set data in the list view

分類Dev

How do I get a list of key, value pairs from the database for a select list in Yii?

分類Dev

Get first value from List of ViewBag in View

分類Dev

How to get a list of UIDs in reverse order with MailKit?

分類Dev

How to order a string list based upon a reference list of string values

分類Dev

How to add the values according to subject

分類Dev

How to set IBAction on view obtained from xib

分類Dev

How to populate jtable checkbox values from database?

分類Dev

Get custom values of variations from order items in WooCommerce

分類Dev

laravel: how to set smtp settings from database

分類Dev

Setting markers in plot according to values in list

分類Dev

list of maps ,get values of a certain key and convert into a set in groovy

分類Dev

How to add column to a dataframe from a list preserving the order of the list

分類Dev

After using groupby, how do I get all values from multiple rows into a list?

分類Dev

How to set default values in Entity Framework 6 (Database First)

分類Dev

How to get a specific list from a list of lists?

分類Dev

IOS Swift - Get values from different nodes in Firebase database

Related 関連記事

  1. 1

    how to get image from drawable according to their names in the sqlite database and then display it in list view

  2. 2

    Set values of column in dataframe according to the order of another column value in python

  3. 3

    How to get ranks from a sample in a list of values?

  4. 4

    Pandas - Sum values in list according to index from another list

  5. 5

    How to fill dropdown list options with values from database in rails?

  6. 6

    how can i parse data from the url from one activity containing using a list view to another activity according to these codes?

  7. 7

    get a set of values from an array

  8. 8

    How to get the list of child nodes from firebase database reference?

  9. 9

    c# - How to get sum of the values from List?

  10. 10

    How to get a list of non duplicate values from one property

  11. 11

    how to get SUM of a set of values from a table then the MAX of those values and echo the 5 highest values

  12. 12

    Get all values from a list of list with jq

  13. 13

    Android: How to maintain set data in the list view

  14. 14

    How do I get a list of key, value pairs from the database for a select list in Yii?

  15. 15

    Get first value from List of ViewBag in View

  16. 16

    How to get a list of UIDs in reverse order with MailKit?

  17. 17

    How to order a string list based upon a reference list of string values

  18. 18

    How to add the values according to subject

  19. 19

    How to set IBAction on view obtained from xib

  20. 20

    How to populate jtable checkbox values from database?

  21. 21

    Get custom values of variations from order items in WooCommerce

  22. 22

    laravel: how to set smtp settings from database

  23. 23

    Setting markers in plot according to values in list

  24. 24

    list of maps ,get values of a certain key and convert into a set in groovy

  25. 25

    How to add column to a dataframe from a list preserving the order of the list

  26. 26

    After using groupby, how do I get all values from multiple rows into a list?

  27. 27

    How to set default values in Entity Framework 6 (Database First)

  28. 28

    How to get a specific list from a list of lists?

  29. 29

    IOS Swift - Get values from different nodes in Firebase database

ホットタグ

アーカイブ