Я пытаюсь получить данные из последней вставленной строки (_id) базы данных. Я не могу понять, что я ошибаюсь / отсутствует. Спасибо за помощь !!
ERROR/AndroidRuntime(363): Caused by: android.database.CursorIndexOutOfBoundsException:
Index -1 requested, with a size of 1
Java:
else { // Otherwise start the application here:
Cursor c = db.rawQuery(
"SELECT * FROM History_List ORDER BY _id desc limit 1",
null);
int nI = c.getColumnIndexOrThrow("intent");
String intent = c.getString(nI);
Class<?> nIntent = null;
try {
nIntent = Class.forName("com.aeroTechnologies.flyDroid."
+ intent);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int tvLabel = c.getColumnIndexOrThrow("label");
String label = c.getString(tvLabel);
int tvTitle = c.getColumnIndexOrThrow("title");
String title = c.getString(tvTitle);
int tvDescript = c.getColumnIndexOrThrow("description");
String descript = c.getString(tvDescript);
int tvURL = c.getColumnIndexOrThrow("gotoURL");
String url = c.getString(tvURL);
int yPOS = c.getColumnIndexOrThrow("scrollY");
String ypos = c.getString(yPOS);
Intent i = new Intent(Start.this, nIntent);
i.putExtra("KEY_LABEL", label);
i.putExtra("KEY_TITLE", title);
i.putExtra("KEY_DESCRIPT", descript);
i.putExtra("KEY_URL", url);
i.putExtra("KEY_INTENT", intent);
i.putExtra("KEY_YPOS", ypos);
startActivity(i);
}