I am trying to retrieve data from SQLite database. code is working fine for all other variables but when it reach at the Pre_result then it throw excetion.
<pre class="default prettyprint prettyprinted">
try{
SQLiteDatabase dbR = DB_Help.getReadableDatabase();
String[] projection = {DB_Help.Pre_ID,DB_Help.Pre_Query,DB_Help.Pre_Results};
Cursor c = dbR.query(DB_Help.Previous_Table,
projection,
null,
null,
null,
null,
null
);
int ii=c.getColumnIndex(DB_Help.Pre_ID);
int iq=c.getColumnIndex(DB_Help.Pre_Query);
int ir=c.getColumnIndex(DB_Help.Pre_Results);
Log.e("C : ", String.valueOf(c));
res_title.setText("ID : "+ii+ " Q : "+iq+" R : "+ir);
for (c.moveToFirst();!c.isAfterLast();c.moveToNext()) {
query_txt.setText(c.getString(iq));
// Code work fine untill this line.
// this line throwing exception of null pointer,
res_txt.setText(c.getString(ir));
}
c.close();
}catch(Exception e){
Log.e("GetResults", "Error in Data Retrival : "+e.toString());
}</pre>
Aucun commentaire:
Enregistrer un commentaire