I am trying to make a simple login page where I can delete a specific contact with its data by simply entering a username.
In other words, I would like to delete a specific row in my database.
public int deleteUsername(String content){ String whereClause = KEY_CONTENT1 + "= '" + content + "'"; return sqLiteDatabase.delete(MYDATABASE_TABLE, whereClause, null); } public int deletePassword(String content){ String whereClause = KEY_CONTENT2 + "= '" + content + "'"; return sqLiteDatabase.delete(MYDATABASE_TABLE, whereClause, null); }
public void onClick(View v) { String username = null; String password = null; username = this.txtnewuserinputedituser.getText().toString().toUpperCase(); password = this.txtnewpasswordinputedituser.getText().toString().toUpperCase(); switch (v.getId()) { case R.id.btndeleteuser : { mySQL.openToWrite(); mySQL.deleteUsername(username); mySQL.deletePassword(password);; mySQL.close(); String toastText = "User Deleted"; Toast.makeText(getApplicationContext(), toastText, Toast.LENGTH_SHORT).show(); break; } } }
The value is that I will need to enter a username and password in editview in order to delete this particular user. I found several sources that told me to use something like this but I tried and it does not work. Is there a mistake?
public int deleteRow(String showId) { String table_name = "MYDATABASE_TABLE"; String where = "showId='"+showId+"'"; return sqLiteDatabase.delete(table_name, where, null); }
I would like to delete a specific row in my database just by taking the username. I enter as the identifier of the row to be deleted. How to do this, or are there any alternatives I can use?
source share