I am pretty new to android application development. In my app ,I am trying to add money to the wallet which is unsuccessful. The logcat does not show any error in the execution.
Here i am posting myDbAdapter.java(database), add_amount.java and activity_add_amount.xml.
The add_amount.java is as follows:
public class Add_Amount extends AppCompatActivity {
TextView amount;
String total;
TextView up;
private no.nordicsemi.android.nrftoolbox.myDbAdapter mydb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add__amount);
up=(TextView)findViewById(R.id.textView_wallet);
amount=(TextView)findViewById(R.id.editText_amount);
String Amount=(String)amount.getText().toString();
mydb = new no.nordicsemi.android.nrftoolbox.myDbAdapter(this);
Cursor rs = mydb.getData(1);
rs.moveToFirst();
String wall=rs.getString(rs.getColumnIndex(no.nordicsemi.android.nrftoolbox.myDbAdapter.CONTACTS_COLUMN_WALLET));
total=Amount+wall;
}
public void addamt(View v){
boolean b=mydb.updateWallet(total,1);
if(b==true)
message(getApplicationContext(),"updated");
else
message(getApplicationContext(),"not updated");
}
}
The updateWallet function in myDbAdapter.java is as follows:
public boolean updateWallet(String amount,Integer id)
{
SQLiteDatabase db=this.getWritableDatabase();
ContentValues contentValues=new ContentValues();
contentValues.put("wallet",amount);
db.update("contacts",contentValues,"id = ? ",new String[] { Integer.toString(id)});
return true;
}
}
When I click the button (Add amount) after entering any amount , toast message "updated" is displayed. But it is not getting updated.
Where is the possible error ?