Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public ProfileTableActivity getStudentById(int Id) {
- SQLiteDatabase db = dbHelper.getReadableDatabase();
- String whereClause = ProfileTableActivity.KEY_ID + "=?";
- String[] whereArgs = {Integer.toString(Id)};
- ProfileTableActivity student = new ProfileTableActivity();
- Cursor cursor = db.query(
- ProfileTableActivity.TABLE,
- ProfileTableActivity.COLUMN_COLLECTION,
- whereClause,
- whereArgs,
- null, null, null);
- if (cursor.moveToFirst()) {
- do {
- student.student_ID =cursor.getInt(cursor.getColumnIndex(ProfileTableActivity.KEY_ID));
- student.name =cursor.getString(cursor.getColumnIndex(ProfileTableActivity.KEY_name));
- student.email =cursor.getString(cursor.getColumnIndex(ProfileTableActivity.KEY_email));
- student.age =cursor.getInt(cursor.getColumnIndex(ProfileTableActivity.KEY_age));
- } while (cursor.moveToNext());
- }
- cursor.close();
- db.close();
- return student;
- }
Advertisement
Add Comment
Please, Sign In to add comment