Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XML Java Android
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...
 

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 21-Feb-13 23:30pm
Edited 22-Feb-13 4:25am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 BillWoodruff 220
4 Mathew Soji 195
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,817
2 DamithSL 5,461
3 Manas Bhardwaj 4,946
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100