views:

12

answers:

1

Here is my LogCat log:

08-25 22:35:27.989: ERROR/AndroidRuntime(327): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 3 

Here is the onCreate(Bundle) method where I get the cursor:

private static final String[] PROJECTION = { 
    Formulas._ID, Formulas.TITLE, Formulas.FORMULA 
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Uri uri = getIntent().getData();

    Cursor formulaCursor = managedQuery(uri, PROJECTION, null, null, null);

    String formulaName = formulaCursor.getString(formulaCursor.getColumnIndex(Formulas.TITLE));
    String formula = formulaCursor.getString(formulaCursor.getColumnIndex(Formulas.FORMULA));

    ((TextView) findViewById(R.id.formula)).setText(formula);
    ((TextView) findViewById(R.id.formula_name)).setText(formulaName);
}

And here is where I actually start the activity:

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Uri formula = ContentUris.withAppendedId(getIntent().getData(), id);
    startActivity(new Intent(Intent.ACTION_VIEW, formula));
}

I already have my own content provider and I set it up properly.

+1  A: 

You didn't do formulaCursor.moveToFirst()?

EboMike