Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.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:从数据库中获取特定行_Android_Mysql - Fatal编程技术网

Android:从数据库中获取特定行

Android:从数据库中获取特定行,android,mysql,Android,Mysql,我有一个大约200行的数据库,我想知道如何从ID50到75获取行。我使用以下代码从数据库中检索所有行 SQLiteDatabase db = this.getWritableDatabase(); String selectQuery = "SELECT * FROM " + TABLE_DETAILS; try { Cursor cursor = db.rawQuery(selectQuery, null); try {

我有一个大约200行的数据库,我想知道如何从ID50到75获取行。我使用以下代码从数据库中检索所有行

SQLiteDatabase db = this.getWritableDatabase();
     String selectQuery = "SELECT  * FROM " + TABLE_DETAILS;
     try {
         Cursor cursor = db.rawQuery(selectQuery, null);
         try {
             if (cursor.moveToFirst()) {
                 do {
                    Log.d("Data", cursor.getString(1));
                        Log.d("Data", cursor.getString(3)));
                    Log.d("Data", cursor.getString(4)));
                    Log.d("Data", cursor.getString(5)));
                 } while (cursor.moveToNext());
             }

         } finally {
             try {
                 cursor.close(); 
             } catch (Exception ignore) {

             }
         }
     } finally {
         try {
             db.close();
         } catch (Exception ignore) {

         }
     }
谢谢,
Sahil

您可以使用where语句,如:

 WHERE ids >= 50 AND ids <= 75

其中ids>=50和ids Upvoting,但我认为该变量称为ROWID而不是ids。或者两者兼而有之,我知道SQLite在那个里有一些别名。谢谢@Gabeschen,我使用了
ids
,因为OPs语句:“如何从ID50到75获取行”,我认为表中的一列是ids。