1

I need help, guys.

You need to flip the listView so that the new record is displayed at the top, and the oldest is at the bottom.

Example:

Original listView:

Apple Pear Banana

It is necessary so:

Banana Pear Apple

DataBaseHelper dataBaseHelper = new DataBaseHelper(this);
    SQLiteDatabase db = dataBaseHelper.getReadableDatabase();
    Cursor cursor = db.query(
            DataBaseHelper.TABLE_NAME,
            null,
            null,
            null,
            null,
            null,
            null);
    String[] args = new String[] {DataBaseHelper.COLUMN_DATE, DataBaseHelper.COLUMN_APPLE,
            DataBaseHelper.COLUMN_PEAR, DataBaseHelper.COLUMN_BANANA};
    int[] tv_laoyout = new int[] {R.id.tvl_date, R.id.tvl_milliage, R.id.tvl_fueltrip, R.id.tvl_cashtrip};
    SimpleCursorAdapter simpleCursorAdapter = new SimpleCursorAdapter(getBaseContext(),R.layout.layout_listview,
            cursor, args, tv_laoyout, 0);
    ListView myList = (ListView)findViewById(R.id.listview);
    myList.setAdapter(simpleCursorAdapter);
    db.close();
    cursor.close();
Funrab
  • 83
  • 1
  • 10
  • You can sort the data that is in the list from most recent record to oldest record, and then call `simpleCursorAdaptor.notifyDatasetChanged();` – Michael Jan 30 '18 at 17:08

1 Answers1

0

you are looking for ordy by, perhaps look at this answer: link

Cursor c = scoreDb.query(DATABASE_TABLE, rank, null, null, null, null, yourColumn+" DESC");
João Carlos
  • 1,405
  • 1
  • 15
  • 21