sqlite - Update password in android studio from another activity -


i have login activity let me insert login , passwords token in sqlite database, want make activity called config let me change password! made method, don't know how use in config activity.

 public class databasehelper extends sqliteopenhelper { //database version private static final int database_version = 1;  // database name private static final string database_name = "usermanager.db";  // user table name private static final string table_user = "user";  // user table columns names private static final string column_user_id = "user_id"; private static final string column_user_name = "user_name"; private static final string column_user_email = "user_email"; private static final string column_user_password = "user_password";  // create table sql query private string create_user_table = "create table " + table_user + "("         + column_user_id + " integer primary key autoincrement," + column_user_name + " text,"         + column_user_email + " text," + column_user_password + " text" + ")";  // drop table sql query private string drop_user_table = "drop table if exists " + table_user;    public databasehelper(context context) {     super(context, database_name, null, database_version); }  @override public void oncreate(sqlitedatabase db) {     db.execsql(create_user_table); }   @override     public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {      //drop user table if exist     db.execsql(drop_user_table);      // create tables again     oncreate(db);  }   public void update_user (string old_pass , string new_pass ) {  this.getwritabledatabase().execsql("update table_user set column_user_password='"+new_pass+ "' column_user_password= '"+old_pass+"'" ); } 

databasehelper db = new databasehelper(this); db.update_user("your old password", "your new password"); 

it's better learn tutorial how use android database.

https://www.androidhive.info/2011/11/android-sqlite-database-tutorial/


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -