Code example for Uri

Methods: getLastPathSegment

0
                case MAIN_ID:
                    // The incoming URI is for a single row. 
                    qb.setProjectionMap(mNotesProjectionMap);
                    qb.appendWhere(MainTable._ID + "=?");
                    selectionArgs = DatabaseUtilsCompat.appendSelectionArgs(selectionArgs,
                            new String[] { uri.getLastPathSegment() });
                    break; 
 
                default: 
                    throw new IllegalArgumentException("Unknown URI " + uri);
            } 
 
 
            if (TextUtils.isEmpty(sortOrder)) {
                sortOrder = MainTable.DEFAULT_SORT_ORDER;
            } 
 
            SQLiteDatabase db = mOpenHelper.getReadableDatabase();
 
            Cursor c = qb.query(db, projection, selection, selectionArgs,
                    null /* no group */, null /* no filter */, sortOrder);