samedi 23 janvier 2016

how to update my record in Database. please look at my code and help me.

enter image description herei am creating notepad application and want to update my notes but i am unable to record in sqlite database. please look at my code and give your suggestions. please check my update query i am sharing error details.

public class MainUpdateActivity extends Activity  { 

SQLiteDatabase mydb1;
EditText titleedit,notetextedit;
Button update;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        titleedit=(EditText)findViewById(R.id.title);
        notetextedit=(EditText)findViewById(R.id.notetext);
        update=(Button) findViewById(R.id.update);

        Intent myintent = getIntent();

        String product7 = myintent.getStringExtra("product1");
        String product8 = myintent.getStringExtra("product");

        titleedit.setText(product7);
          notetextedit.setText(product8);

update.setOnClickListener(new View.OnClickListener()
            {

            public void onClick(View v)
            {
mydb1.execSQL("UPDATE notes SET (title,notetext) values(?,?);",new String[]{titleedit.getText().toString(),notetextedit.getText().toString()});

Toast.makeText(getApplicationContext(), "note Updated", 3000).show();



            Intent myIntent1 = new Intent(MainUpdateActivity.this,menu.class);

            startActivity(myIntent1);

            finish();

            }

            });

Aucun commentaire:

Enregistrer un commentaire