How do I limit the number of rows in a listview

1

I have a listview which is adapted with a cursoradapter ... it selects everything from the database and adapt in my listview .... but I wanted to limit the amount of rows that appear in my listview ... more or less so .. wanted to select all the data that I have but that showed only 10 ... regardless of the number of data in the bank .... thanks

    
asked by anonymous 10.07.2017 / 03:14

1 answer

1

Just limit the SQL query to the bank. In your case it would look like this:

SELECT coluna FROM tabela ORDER BY algo LIMIT 10

If you are using the query () method of the SqliteDatabase class, you can do the same query as above:

db.query (null, 
            tabela, 
            New String[]{coluna}, 
            null, 
            null, 
            null, 
            null, 
            algo, 
            "10");
    
10.07.2017 / 03:31