I've been trying to update my database when i click the FloatingActionButton using the code below. But something is wrong.
year=intent.getIntExtra("year",0);
fabUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TextView t=(TextView)findViewById(R.id.textView2);
t.setText("year:"+year);
ContentValues a=new ContentValues();
a.put("YEAR",year);
db.update("EXAMTABLE", a, "_id=?", new String[]{String.valueOf(position)});
}
});
TextView t
displays the year properly(for example "year:2016"). But the database is not gettting updated with that year.
If i substitute year=intent.getIntExtra("year",0);
with year=2016;
directly,the database gets updated properly.
Can someone please help me understand what is wrong here, or what is causing this. And how i can make it get updated with the value passed through the intent.
Aucun commentaire:
Enregistrer un commentaire