Click here to Skip to main content
15,886,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all..
i m very new to android development...i have created one app which works well for inserting into and selecting data from database...
but i don't know how to update data in database...
here is code i have tried...but get NullPointerException...


Java
if (v.getId()==R.id.btnUpdate)
          {
            Cursor value = null ;


            dbAdaptert.open();
            String name=value.getString(value.getColumnIndex("name"));

             String pass=etpass.getText().toString();
             String uname=etuname.getText().toString();

            long update=dbAdaptert.updateTest(name, uname, pass);

            if(update>=0)
            {
                Toast.makeText(getApplicationContext(), "Data updated",Toast.LENGTH_LONG).show();

            }
            else
            {
                Toast.makeText(getApplicationContext(), "Data not updated",Toast.LENGTH_LONG).show();

            }
            dbAdaptert.close();



          }
Posted
Updated 22-Feb-13 3:25am
v3

1 solution

there is a update command for that:

android.database.sqlite.SQLiteDatabase. update (String table, ContentValues values, String whereClause, String[] whereArgs)[^]

please also take a look at the great tutorial by Lars Vogel upon working with SQlite in Android:

http://www.vogella.com/articles/AndroidSQLite/article.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900