Utman Alami
Utman Alami

Reputation: 131

insertion in the same row for all activities

i am here to ask for help again, my problem is that in first activity i have values that i insert into database , in the second activity when i try to insert the values it creates a new row, what i want is the values of second activity completes the row of the first activity. And also how could i refer to the last row ??

i don't know how to do it! so, is there any ideas ?

 public void updateMENAGE(int id, int a16, int b17, String rm_18_1ts,
        String rm_18_2ts, int c19, int d20, int e21) {

      ContentValues values = new ContentValues();
      values.put(col_Type_habitat,a16);
      values.put(col_Statut_occupation ,b17);
      values.put(col_Nombre_ménages_habitant_logement,rm_18_1ts);values.put(col_Nombre_pièces_occupes_ménage,rm_18_2ts);
      values.put(col_Mode_principal_approvisionnement_eau_potable, c19);
      values.put(col_Mode_principal_éclairage,d20);
      values.put(col_Mode_principal_assainissement,e21);

       db.update(MENAGE,values,_id+"="+id, null);
        }

public class ActivityDeux extends Activity {

  DBAdapter db = new DBAdapter(this);
  public void  ajouter(View v) {
        db.open();

        db.updateMENAGE(1,a16,b17,rm_18_1ts,rm_18_2ts,c19,d20,e21);
        db.close();                     
        } 

Upvotes: 0

Views: 57

Answers (1)

Dragan
Dragan

Reputation: 328

You don't need to insert new record. You need to update existing record. That is your solution

Upvotes: 1

Related Questions