I have the following application Where the user have to signup with (Email ,pass ,Hight ,Weight).. then he will login with Email and pass -> choose Calculate BMI option -> Here in this activity i want to display the result of BMI calculation for the logged in user .. is their any way to retrieve the (Weight,Hight) in the BMIActivity or i have to pass it with intent ?
I used SQLite Database Helper.
I just want a guider how to think about this.
Below is the homepage code for the button
public void onClick(View view){
if(view==BMI){
cursor = db.rawQuery("SELECT * FROM " + DatabaseHelper.R_TABLE_NAME + " WHERE " + DatabaseHelper.R_COL_10 + "=? AND " + DatabaseHelper.R_COL_11 + "=?" , new String[]{Weight,Hight});
if(cursor!=null){
if (cursor.getCount()>0) {
cursor.moveToNext();
String Weight = cursor.getString(cursor.getColumnIndex(DatabaseHelper.R_COL_10));
String Hight = cursor.getString(cursor.getColumnIndex(DatabaseHelper.R_COL_11));
Intent i = new Intent(HomepageNActivity.this, BMIActivity.class);
i.putExtra("Weight",Weight);
i.putExtra("Hight",Hight);
startActivity(i);
}
}
}
Below is the BMI calculation activity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bmi);
openHelper=new DatabaseHelper(this);
db = openHelper.getWritableDatabase();
TextView TBMI= (TextView) findViewById(R.id.textView13);
cursor = db.rawQuery("SELECT * FROM " + DatabaseHelper.R_TABLE_NAME + " WHERE " + DatabaseHelper.R_COL_10 + "=? AND " + DatabaseHelper.R_COL_11 + "=?" , new String[]{Weight,Hight});
if(cursor!=null){
if (cursor.getCount()>0) {
cursor.moveToNext();
String Weight = cursor.getString(cursor.getColumnIndex(DatabaseHelper.R_COL_10));
String Hight = cursor.getString(cursor.getColumnIndex(DatabaseHelper.R_COL_11));
}}