rawQuery(query, selectionArgs)

后端 未结 7 1257
不思量自难忘°
不思量自难忘° 2020-11-30 22:32

I want to use select query for retrieving data from table. I have found, rawQuery(query, selectionArgs) method of SQLiteDatabase class to retrieve

相关标签:
7条回答
  • 2020-11-30 23:00

    For completeness and correct resource management:

            ICursor cursor = null;
            try
            {
    
                cursor = db.RawQuery("SELECT * FROM " + RECORDS_TABLE + " WHERE " + RECORD_ID + "=?", new String[] { id + "" });
    
                if (cursor.Count > 0)
                {
                    cursor.MoveToFirst();
                }
                return GetRecordFromCursor(cursor); // Copy cursor props to custom obj
            }
            finally // IMPORTANT !!! Ensure cursor is not left hanging around ...
            {
                if(cursor != null)
                    cursor.Close();
            }
    
    0 讨论(0)
提交回复
热议问题