K
K
Koshkasobaka2021-07-11 17:24:01
Android
Koshkasobaka, 2021-07-11 17:24:01

How to add a new recyclerView item to the top of the list?

I am using SQLite. When I click the save button after creating the element, I call the function in DbManager:

fun insertToDb(title: String, content: String, imageUri: String) { 
 val values = ContentValues().apply { 
 put(DbName.COLUMN_TITLE, title) 
 put(DbName.COLUMN_CONTENT, content) 
 put(DbName.COLUMN_IMAGE_URI, imageUri) 
 } 
 db?.insert(DbName.NOTE_TABLE, null, values) 
 }

But the element is inserted at the end of the list, but how can I add it to the beginning?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-07-11
@Koshkasobaka

In general, the database has the right to give data in an arbitrary order, so explicitly set order by in the request for the field you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question