Android SQLite Database Tutorial 5 # Update values in SQLite Database table using Android

Android SQLite Database Tutorial 5 # Update values in SQLite Database table using Android

ProgrammingKnowledge

9 лет назад

230,952 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

thadeu sysnnys
thadeu sysnnys - 21.11.2022 22:40

안녕하세요, 작업을 축하합니다. 나도 좋아 BRZ11990003036 🇧🇷

Ответить
Hassham Sahir
Hassham Sahir - 16.06.2022 10:45

The update function in DataBaseHelper Class is always returning true no matter data is updated or not, so it will always show data is updated.

Ответить
Shem Brooklyne
Shem Brooklyne - 21.08.2021 17:15

From mid 2021 and you just saved my life MR!
THANK YOU!!!!!!!!!!!!!!!!!!!!

Ответить
Knowledge Quest
Knowledge Quest - 25.02.2021 13:42

Any one can help I use complete method by seeing this video but my database is not created

Ответить
Pruthvi Shinde
Pruthvi Shinde - 22.11.2020 07:32

Data is not updating please help

Ответить
Kushala R
Kushala R - 25.08.2020 10:02

Thank you for the superb tutorial,, really really very helpful and easy way to understand.

Ответить
Arief Yudhawarman
Arief Yudhawarman - 28.06.2020 14:29

I suggest function updateData like below, it returns integer.
public int updateData (String id, String name, String surname, String marks) {
db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(COL_1, id);
contentValues.put(COL_2, name);
contentValues.put(COL_3, surname);
contentValues.put(COL_4, marks);
String[] IDs = {id};
return db.update(TBL_NAME, contentValues,"ID = ?",IDs); // successfull return 1 else return 0
}
Then on the calling method
...
if (isUpdate == 1)
Toast.makeText(MainActivity.this, "Data updated.", Toast.LENGTH_LONG).show();
else
Toast.makeText(MainActivity.this, "ID not found.\nData not updated.", Toast.LENGTH_LONG).show();
So if update succesfull the function updateData will return 1 else 0.

Ответить
עמית שלו
עמית שלו - 01.04.2020 01:37

bro ty so much!

Ответить
VA coder [ Tech ]
VA coder [ Tech ] - 20.01.2020 03:04

It says array dimension missing

Ответить
Akshay Jain
Akshay Jain - 31.12.2019 10:45

thank you very much .. cool stuff there , i have question that why did you pass only id in string[ ] , why not all(name , surname etc) ... i didn't get this

Ответить
Random
Random - 08.10.2019 01:34

can u make videos on where query is applied for viewing data

Ответить
Sainath RS
Sainath RS - 17.09.2019 14:24

can any reply plzzzzzz

Ответить
Sainath RS
Sainath RS - 16.09.2019 15:52

can any give mw rply???

Ответить
Sainath RS
Sainath RS - 16.09.2019 12:11

is any one there to help me out ??

Ответить
Sainath RS
Sainath RS - 16.09.2019 10:39

Hai this is sainath can any one help me insert,Update and delete data in mssql database using android studio can any one reply me plzzz....

Ответить
Parikshit Raghav
Parikshit Raghav - 30.07.2019 16:31

Thanks for sharing your knowledge with us. May God bless you man.

Ответить
Saman Arianpour
Saman Arianpour - 28.03.2019 12:01

this guy is sexy af :D

Ответить
Brian Ramírez
Brian Ramírez - 11.03.2019 10:24

man you are my hero.

Ответить
Ricardo W.
Ricardo W. - 29.08.2018 09:27

Thanks again!

Ответить
Tefera Mngesha
Tefera Mngesha - 29.12.2017 23:03

Hi parogrammingKnowledge thank you very much for your video tutorial.I was appreciate if you could make in video call and in SMS messaging application. thank you again.

Ответить
quieromicubita
quieromicubita - 21.12.2017 18:37

Thanks for this super clear tutorial

Ответить
Jose Georges
Jose Georges - 06.11.2017 23:57

just one question, when I put an ID that is not on my table, even though it does not update it still sends me "Data Updated Successfully", what would be the reason of this?

Ответить
Boris Kunda
Boris Kunda - 21.10.2017 10:14

data is not updating only showing toast message .....need help

Ответить
alberto cassio
alberto cassio - 30.08.2017 10:52

I would like to display data on a list view rather than a message from string buffer. Could you please show me how ?

Ответить
Swathi J S Rao
Swathi J S Rao - 30.07.2017 14:49

thank you..sir..
very informative lecturing

Ответить
darkman237
darkman237 - 06.06.2017 22:22

So what happens if someone types in the wrong id?

Ответить
darkman237
darkman237 - 06.06.2017 22:02

How would you be able to view all and tap the one you want to change or delete?

Ответить
Samii
Samii - 01.06.2017 12:09

respected sir i have a request that sir the tutorial vidio are not so much clear pic we don't understand that what coding is done sir please give me some suggestion that what i do sir i well be very thinkful of you sir

Ответить
Tabai smida
Tabai smida - 22.05.2017 15:47

Can U help me please with that... !!!
android.database.sqlite.SQLiteException: no such column: ID (code 1): , while compiling: UPDATE student_table SET ID=?,NAME=?,SURNAME=?,MARKS=? WHERE ID= ?

Ответить
Giovanni Ciavarelli
Giovanni Ciavarelli - 30.04.2017 20:04

Hello! Thank you for this tutorial ... I need to update a single value on a specific row ... how could I do? Thanks!

Ответить
Harjinder singh
Harjinder singh - 15.04.2017 12:18

@ProgrammingKnowledge can you tell me how to store image in SQLite Database

Ответить
Aryan Vedh
Aryan Vedh - 04.02.2017 19:40

Hi ProgrammingKnowledge, Thank you very much for amazing Tutorial. I was wondering, if you could make tutorial on bottom bar? I tried to look for tutorials, but some how they dont work when applied in my app, I will really appreciate it :)

Thank you :)

Ответить
jesus king
jesus king - 06.01.2017 08:04

i got this error:

FATAL EXCEPTION: main
Process: com.example.jesusalvelo.sqlite, PID: 2438
android.database.sqlite.SQLiteException: near "fromstudent_table": syntax error (code 1): , while compiling: select * fromstudent_table

could it be this part?
public Cursor getAllData(){
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery("select * from"+TABLE_NAME,null);
return res;
}

Ответить
Jonathan Langford
Jonathan Langford - 02.12.2016 23:51

Thank you so much

Ответить
shubham raja
shubham raja - 13.11.2016 21:26

update not successful but still give messege that updated successfully

Ответить
Bereshyit Bara
Bereshyit Bara - 07.11.2016 16:14

AS 2.2.1 is so awesome and powerful that following source codes are given automatically:
public Cursor getAllData() {
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery("select * from "+TABLE_NAME,null);
return res;
}

public boolean updateData(String id,String name,String surname,String marks) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(COL_1,id);
contentValues.put(COL_2,name);
contentValues.put(COL_3,surname);
contentValues.put(COL_4,marks);
db.update(TABLE_NAME, contentValues, "ID = ?",new String[] { id });
return true;

Ответить
giang huong
giang huong - 19.08.2016 08:49

Tutoria code backup name, Surname & marks in updaite SQLite

Ответить
giang huong
giang huong - 19.08.2016 08:48

Tutoria backup name, Surname & marks in updaite

Ответить
giang huong
giang huong - 19.08.2016 08:47

Tutoria backup name, Surname & marks in updaite

Ответить
Shoaib Ahmed
Shoaib Ahmed - 13.08.2016 14:55

You are really good, please come up with more advance concepts like android Material Design and motions

Ответить
Tweheyo Ivan
Tweheyo Ivan - 09.08.2016 14:48

thanks for your gud tutorials on sqlite ....ts awesome

Ответить
Aditya Kulkarni
Aditya Kulkarni - 10.07.2016 18:21

My emulator does not start and neither my mobile is root so i cant see the table. Is there another way to see the table? Please help me.

Ответить
arthur class
arthur class - 08.07.2016 14:47

This is not the best way to do an update because the id is automatically assigned ,you can't assign an Id yourself which makes the app limited

Ответить
Yousef Almutairi
Yousef Almutairi - 16.06.2016 09:29

DATA IS ALWAYS UPDATED AND NEVER SAYS "Data is NOT updated"

Ответить
Soham Ashtekar
Soham Ashtekar - 15.04.2016 22:24

Please Reply to this I want to add new values to existing value what should i do. Like if my db have 10 value in marks column and if i want to add 20 in it and want to update in that way what should i do. My application is almost ready just waiting for this issue. Please reply asap. And thanks for your videos .:)

Ответить
Zaid Zakir
Zaid Zakir - 14.02.2016 11:39

good video, but bad programming concept for real life example. entering id manually is not good practice shuld be automatically done, anyways good video.

Ответить
K Horst
K Horst - 26.01.2016 00:21

It says Data is updated , but it is not :(

Ответить
Saurabh Agrawal
Saurabh Agrawal - 04.01.2016 13:30

thanks.. tutorials are awesome to start with.
Please provide the link for source codes as well

Ответить