mardi 13 octobre 2015

How to I make delete function require password in SQLite Android

How to I make delete function require password in SQLite Android. Currently I'm able to delete my stored information, but I want to make the delete button to have password function so that only user can delete it. The password should be hard coded

my codes:

MainActivity.java

public void DeleteResult(View view) {
        if (txtName.getText().length() == 0)
            Toast.makeText(this, "Please select contact to be deleted!", Toast.LENGTH_LONG).show();

        else {
            Result tmp = new Result(txtName.getText().toString(), ratingBar.getRating());
            db.deleteResult(tmp);
            DisplayAll();
            Toast.makeText(this, "Contact Deleted!", Toast.LENGTH_LONG).show();
        }
    }

DatabaseHandler.java

 public void deleteResult(Result result) {
            SQLiteDatabase db = this.getWritableDatabase();
            db.delete(TABLE_RESULT, KEY_NAME + " =?", new String[]{String.valueOf(result.getName())});
            db.close();
        }

Aucun commentaire:

Enregistrer un commentaire