Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在sqlite中按降序显示数据库中的数据?_Android_Sqlite_Listview - Fatal编程技术网

Android 如何在sqlite中按降序显示数据库中的数据?

Android 如何在sqlite中按降序显示数据库中的数据?,android,sqlite,listview,Android,Sqlite,Listview,我在SQLite中有一个表,如下所示 我想根据单击列在android listview中显示它。这意味着下降 类似于3,1,0的顺序使用SimpleCursorAdapter,创建查询时,指定“单击描述”作为排序顺序(managedQuery()的最后一个参数)。使用SimpleCursorAdapter,创建查询时,指定“单击描述”作为排序顺序(managedQuery()的最后一个参数).您需要使用“ORDER BY”子句查询数据库。它看起来像这样 Cursor cursor = data

我在SQLite中有一个表,如下所示

我想根据单击列在android listview中显示它。这意味着下降
类似于3,1,0的顺序使用
SimpleCursorAdapter
,创建查询时,指定“单击描述”作为排序顺序(managedQuery()的最后一个参数)。

使用
SimpleCursorAdapter
,创建查询时,指定“单击描述”作为排序顺序(managedQuery()的最后一个参数).

您需要使用“ORDER BY”子句查询数据库。它看起来像这样

Cursor cursor = database.query(TABLE_NAME, new String[] {"_id", "quote", "click"}, null, null, null, null, "click DESC");

cursor.moveToFirst(); // this will get the cursor ready to be used in an adapter

setListAdapter(new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor, new String[] {"quote"}, new String[] {android.R.id.text1});

假设列表用于引号,并且您正在ListActivity中工作,则需要使用“ORDER BY”子句查询数据库。它看起来像这样

Cursor cursor = database.query(TABLE_NAME, new String[] {"_id", "quote", "click"}, null, null, null, null, "click DESC");

cursor.moveToFirst(); // this will get the cursor ready to be used in an adapter

setListAdapter(new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor, new String[] {"quote"}, new String[] {android.R.id.text1});

假设列表是用于引号的,并且您正在ListActivity中工作,那么是否可能抛出sqlite qureyYes,确实如此。SQLite支持订购。你能给我一个问题吗?有没有可能抛出SQLite qureyYes,是的。SQLite支持订购。您能给我查询一下吗