Code example for CursorAdapter

    private LayoutInflater mLayoutInflater;
    private SharedPreferences mPrefs;
    public SearchResultsAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
        mLayoutInflater = (LayoutInflater) context
        mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    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);
Experience pair programming with AI  Get Codota for Java