Nama
Nama

Reputation: 308

How to modify the database values through user interface?

I am doing a small program in android, I'm able to store the data through the registration page into the database and after the user logged in I can display the particular details.

And now I am trying that, if user wants to modify his data, he is able to replace the original values in the database, for this I used a button, when the user pressed the button again the registration page have to come with the user details and when he modifies and presses the submit button the old record should delete and the new values shall store in with same id. and i have one more requirement, that is to restrict the existing username. For this i used a search method and store the values in cursor, and now i don't know how to compare the username with the cursor values.

How can I do this?

Upvotes: 0

Views: 915

Answers (2)

waqaslam
waqaslam

Reputation: 68187

use update method to change values in tables. Read this

for example, Id 1 has name Srikinath, and you would like to change it to Nama:

ContentValues args = new ContentValues();
args.put("columnName", "Nama");
boolean isUpdated = db.update("myTable", args, String.format("%s = '%s'", "columnId", "1"), null) > 0;

Upvotes: 0

Srikanth
Srikanth

Reputation: 164

Use the Cursor to get the values from database and display those values in same reg from and use sqlite to update those new values.

Upvotes: 2

Related Questions