Hi,
I am newer to android program. After a couple of days learning content provider for data process. I understand basic, but I still confuse with the following, please explain it to me.
case STUDENT_ID:
qb.appendWhere( _ID + "=" + uri.getPathSegments().get(1));
break;
//I know getPathSegments(), will return a list of elements based on uri.
// My uri is "com.example.provider.College/students/a_Id_num". The a_Id_num could be an auto-// // created number, e.g. 1 or 4 or 6, etc.
//My question is: _ID = 1 only, or _ID = a collection of 1, 4, 6, .. ????
// It looks like: _ID =1, but the following codes:
Cursor c = qb.query(db, projection, selection, selectionArgs, //the where cause is now built into qb.
null, null, sortOrder);
//and after c return to main activity's calling method:
Cursor c = managedQuery(students, null, null, null, "name");
if (c.moveToFirst()) {
do{
Toast.makeText(this,
c.getString(c.getColumnIndex(StudentsProvider._ID)) +
", " + c.getString(c.getColumnIndex( StudentsProvider.NAME)) +
", " + c.getString(c.getColumnIndex( StudentsProvider.GRADE)),
Toast.LENGTH_SHORT).show();
} while (c.moveToNext())
//I run the app, all the records (not only the record links to _ID =1) will display one at a time on emulator.
What happens ?
Thanks,
Sunny
I am newer to android program. After a couple of days learning content provider for data process. I understand basic, but I still confuse with the following, please explain it to me.
case STUDENT_ID:
qb.appendWhere( _ID + "=" + uri.getPathSegments().get(1));
break;
//I know getPathSegments(), will return a list of elements based on uri.
// My uri is "com.example.provider.College/students/a_Id_num". The a_Id_num could be an auto-// // created number, e.g. 1 or 4 or 6, etc.
//My question is: _ID = 1 only, or _ID = a collection of 1, 4, 6, .. ????
// It looks like: _ID =1, but the following codes:
Cursor c = qb.query(db, projection, selection, selectionArgs, //the where cause is now built into qb.
null, null, sortOrder);
//and after c return to main activity's calling method:
Cursor c = managedQuery(students, null, null, null, "name");
if (c.moveToFirst()) {
do{
Toast.makeText(this,
c.getString(c.getColumnIndex(StudentsProvider._ID)) +
", " + c.getString(c.getColumnIndex( StudentsProvider.NAME)) +
", " + c.getString(c.getColumnIndex( StudentsProvider.GRADE)),
Toast.LENGTH_SHORT).show();
} while (c.moveToNext())
//I run the app, all the records (not only the record links to _ID =1) will display one at a time on emulator.
What happens ?
Thanks,
Sunny