0

hi i have a form in my xml with all infos and i wanna create a button to update some elements (one button for one element....) my code is :

private int id; 
private String surnom; 

public int getid() 
{ return id;  }       
public void setId(int id) 
{ this.id = id; } 

public String getsurnom() 
{ return surnom;  }       
public void setsurnom(String surnom) 
{ this.surnom = surnom; }


public void addListenerOnButton00() {
button = (Button) findViewById(R.id.bouton00);
button.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View arg0) {
        String packageName = context.getPackageName();
        String DB_PATH = String.format("//data//data//%s//databases//", packageName);
        String path = DB_PATH + DB_NAME;
        database = SQLiteDatabase.openDatabase(path, null,
        SQLiteDatabase.OPEN_READWRITE);
        Log.e(this.getClass().toString(), "Opening database for update");

        ContentValues values=new ContentValues();
        values.put("surnom",getsurnom());
        database.update("mabase", values, "_id=" + id, null);

        database.close();
        Log.e(this.getClass().toString(), "closing database after update");
     }
 });
}   

i have no errors when i click the button but nothing is updated can you help me?

logs are here to make me see on logcat that code is well executed.

Lapetole
  • 1
  • 2

2 Answers2

-1

Have a look on this

it will be useful....

ROHIT PARMAR
  • 901
  • 15
  • 26
-1

Here is one tutorial which may help you.It has a form through which you can insert values.You can view the values. Also you can update or delete the values from List.Have a look at it!

http://chintankhetiya.wordpress.com/2013/06/01/sqlite-database-example/

Jigar Pandya
  • 2,129
  • 2
  • 17
  • 27