File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed
app/src/main/java/com/alaminkarno/sqlitedatbase Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -63,9 +63,8 @@ public Cursor searchData(int ID){
63
63
String SEARCH_QUERY = "select * From " +TABLE_NAME +" where " +COL_ID +" = " +ID ;
64
64
65
65
SQLiteDatabase sqLiteDatabase = getReadableDatabase ();
66
- Cursor cursor = sqLiteDatabase .rawQuery (SEARCH_QUERY ,null );
66
+ return sqLiteDatabase .rawQuery (SEARCH_QUERY ,null );
67
67
68
- return cursor ;
69
68
}
70
69
71
70
public boolean updateData (int id ,String name ,String age ){
Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ public void search(View view) {
71
71
72
72
while (cursor .moveToNext ()){
73
73
74
- String name = cursor .getString (cursor .getColumnIndex ( databaseHelper .COL_NAME ));
75
- String age = cursor .getString (cursor .getColumnIndex ( databaseHelper .COL_AGE ));
74
+ String name = cursor .getString (cursor .getColumnIndexOrThrow ( DatabaseHelper .COL_NAME ));
75
+ String age = cursor .getString (cursor .getColumnIndexOrThrow ( DatabaseHelper .COL_AGE ));
76
76
77
77
AlertDialog .Builder builder = new AlertDialog .Builder (this );
78
78
builder .setTitle ("Search Result for ID: " +ID );
You can’t perform that action at this time.
0 commit comments