Code example for CursorAdapter

0
    private LayoutInflater mLayoutInflater;
 
    private SharedPreferences mPrefs;
 
    public SearchResultsAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
        mLayoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    } 
 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) {
        if (!mDataValid) { 
            throw new IllegalStateException("this should only be called when the cursor is valid");
        } 
        if (!mCursor.moveToPosition(position)) {
            throw new IllegalStateException("couldn't move cursor to position " + position);
        } 
 
        final ViewHolder viewHolder;