SQLite + Android - Update Table Data (Book Library App) | Part 4

  Рет қаралды 74,886

Stevdza-San

Stevdza-San

Күн бұрын

🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN
stevdza-san.com
🐱‍👤 Wanna become a member? Join!
/ @stevdzasan
📸 Instagram
/ stevdza_san
We are going to create a Book Library application. Our application will have all the necessary functionality which every app with database should have. That includes CRUD, or Create, Read, Update and Delete functions. Also I'm going to teach you how to add Recyclerview and display data from our SQLite database in it. We are going to add some animations as well.
Project Files: github.com/ste...
Part 1 (Create Database Schema) - • SQLite + Android - Cre...
Part 2 (Insert Data in Database Table) - • SQLite + Android - Ins...
Part 3 (Display Data in Recyclerview) - • SQLite + Android - Dis...
----------
Part 5 (Delete Table Data) - • SQLite + Android - Del...
Part 6 (Animate Recyclerview) - • SQLite + Android - Ani...
One of the main principles of SQL databases is the schema: a formal declaration of how the database is organized. The schema is reflected in the SQL statements that you use to create your database. You may find it helpful to create a companion class, known as a contract class, which explicitly specifies the layout of your schema in a systematic and self-documenting way.
A contract class is a container for constants that define names for URIs, tables, and columns. The contract class allows you to use the same constants across all the other classes in the same package. This lets you change a column name in one place and have it propagate throughout your code.

Пікірлер: 163
@HausCoding
@HausCoding 4 жыл бұрын
If you update data but not change anything. Add code before db.updateData(); in file UpdateActivity.java title=title_input.getText().toString().trim(); author=author_input.getText().toString().trim(); pages=pages_input.getText().toString().trim();
@andrifirmansaputra409
@andrifirmansaputra409 4 жыл бұрын
Thanks bro 👍
@HausCoding
@HausCoding 4 жыл бұрын
@@rizqinrizwan9388 You're welcome
@HausCoding
@HausCoding 4 жыл бұрын
@@andrifirmansaputra409 yeah youre welcome
@nancy7092
@nancy7092 4 жыл бұрын
OMG! thankyou so much :")))
@theblaze8643
@theblaze8643 4 жыл бұрын
thanks :D
@mazenbinsalem
@mazenbinsalem 4 жыл бұрын
Hi Stevdza, Thanx a lot for your awesome, short, fast, clear and useful tutorials,. Keep it up! However @1:31 on MyViewHolder inner class I have used ConstraintLayout for mainLayout instead of LinearLayout as it was the reason why my app crashes whenever I start the app while any data are available on the database. Also, on 10:41 on UpdateActivity you add 3 rows of code after MyDataBaseHelper db.. as following : title = title_input.getText().toString().trim(); author = author_input.getText().toString().trim(); pages = pages_input.getText().toString().trim(); db.update... this code is add but not mentioned. Also, activity_update.xml
@alanpintor9009
@alanpintor9009 2 жыл бұрын
At minute 2:24, my parameter "int position" does not change to "final int position" and I am getting an error when running the app. Error: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference Help, please!
@alanpintor9009
@alanpintor9009 2 жыл бұрын
Solution: For the error message "...null object reference" I corrected my findViewById() reference. For the parameter error, I replace View.OnClickListener() for lambdas
@FinalTie
@FinalTie Жыл бұрын
@@alanpintor9009 hey bro I have the same error can you tell me how you corrected it
@centurionzo1228
@centurionzo1228 2 ай бұрын
I have the same problem, i could not solved it
@centurionzo1228
@centurionzo1228 2 ай бұрын
My app just crashs, I couldn't manage to solve it
@wheepup8452
@wheepup8452 3 жыл бұрын
When I select an item in the recyclerView and UpdateActivity is opened it never loads any data. The code is the same. Please help
@assemabujahal625
@assemabujahal625 3 жыл бұрын
Thanks to you I finished my project 💚💚💚
@TheTejasDalvi
@TheTejasDalvi 3 жыл бұрын
when I click on any card , getting all the edittexts empty ,what I suppose to do? Changes in my code- I have made one books class and all data init to use search functionality. And I'm using { Books obj; obj.get(position); string.valueof(obj.getid); } instead of { string.valueof(id.get(position)); } . And I created methods like getid in books class. is this cause of my problem? I coded upto 5:45
@centurionzo1228
@centurionzo1228 2 ай бұрын
Hello there, i having problems, for some reason my int position stay in red and don't actomatically change to Final int position, is also don't open the app, it's just don't work
@minhuyk6vd
@minhuyk6vd 3 жыл бұрын
Thanks to you I finished my test ^^
@StevdzaSan
@StevdzaSan 3 жыл бұрын
Glad to hear that! :)
@jhazerandrade4120
@jhazerandrade4120 2 жыл бұрын
How to navigate the database helper class? in the 10:40 - 10:41 seems like magic so fast can't keep up
@vibhathakur5751
@vibhathakur5751 4 жыл бұрын
Unable to add refresh functionality
@alanpintor9009
@alanpintor9009 2 жыл бұрын
I missed the code change you magically made in minutes 10:40 to 10:41. That was too fast man! lol 😆 I needed to watch the video many times to catch it.
@StevdzaSan
@StevdzaSan 2 жыл бұрын
You need to stay sharp and focused. 😎
@funzone9462
@funzone9462 5 жыл бұрын
Nice Search option and alphabet a- z list view . Long click to edit data and onclick open Next activity and show details with title , author/description and number . Then user can easily able to access .data
@StevdzaSan
@StevdzaSan 5 жыл бұрын
I havent added search option in this project, but in some future video I'll do that
@HereYouGOsino
@HereYouGOsino 4 жыл бұрын
is it hard to implement search functionality in this ?
@shepard_t
@shepard_t 4 жыл бұрын
Hi Stevdza-San, thanks for the awesome tutorial. I would like to know what the getAndSetIntentData method would look like if the input is a spinner and I want to change to another spinner item. Many thanks!
@wheepup8452
@wheepup8452 3 жыл бұрын
Instead of pressing the recycler view to edit have a button (since it's only 1 person). I did everything the same. The only difference is that I call the updateData function in a different activity. The one that contains the recycler View and the edit Button. Since the onClick is in a different activity (the one that has the button) I didn't do the intents in the CustomAdapter, but in the Activity. they are the same without 'holder' and 'position'. like so: Height = getIntent().getStringExtra("Height"); Now when I enter the info and press update the app crushes. Any ideas? I'm new at coding so I apologise if I didn't explain i very well
@hunsendrake2535
@hunsendrake2535 Жыл бұрын
is it possible to update only in an specific column?
@mahararahma
@mahararahma 3 жыл бұрын
Hi bro thanks fo the tutorial🙌🏻 it really help alot Send much love for u
@StevdzaSan
@StevdzaSan 3 жыл бұрын
I'm glad to help!
@janettaylor260
@janettaylor260 3 жыл бұрын
Hi Stev, unfortunately as of February 2022 this does not work as getposition is deprecated. Please can you do an update? Thanks
@StevdzaSan
@StevdzaSan 3 жыл бұрын
My suggestion is to switch to ROOM library. I have a playlist for that as well.
@roshanm420
@roshanm420 4 жыл бұрын
Very useful tutorial thank you sir
@ankonsarkar9657
@ankonsarkar9657 Жыл бұрын
Ho no ... i missed to show Edittext Data getting... 10:40 min update_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //And only then we call this try (MyDatabaseHelper myDB = new MyDatabaseHelper(UpdateActivity.this)) { title = title_input.getText().toString().trim(); author = author_input.getText().toString().trim(); pages = pages_input.getText().toString().trim(); myDB.updateData(id, title, author, pages); } } });
@thecompilerbro
@thecompilerbro 3 ай бұрын
Thanks a lot. Now it's updating on clicking the Update button.
@Waleed_Al-Haidary
@Waleed_Al-Haidary 4 жыл бұрын
I did everything as explained, just couldn't figure out why the strings such as "title", "author", "pages" has green underline, the app crash when when I click on the item name for the screen that recall the details of the item for update/delete?? any ideas folks.
@StevdzaSan
@StevdzaSan 4 жыл бұрын
Download the project files which I uploaded on Github and compare with your code.
@Waleed_Al-Haidary
@Waleed_Al-Haidary 4 жыл бұрын
​@@StevdzaSan Thank you for your support, I did compared your files on github with my files and found my mistakes, THANKS AGAIN.
@deveshsingh4214
@deveshsingh4214 3 жыл бұрын
from 10:40 to 10:41 ... update_button.setOnClickListener{...} the code changes. This would be causing issues... BTY Its 1 year Old...😂😅
@juanenriquez2798
@juanenriquez2798 3 жыл бұрын
is there a code for me to follow where i could add a button as a counter for the books entered and display the number as well?
@alexnewcomer475
@alexnewcomer475 4 жыл бұрын
At 11:47 onBindViewHolder method is shown and it has been changed since the last time we saw it with the override on click removed and nowhere to be seen. I try to recreate the code you show on the screen and get errors. And when I run my program the values don't show as updated please advise. Thanks.
@StevdzaSan
@StevdzaSan 4 жыл бұрын
Feel free to download project files and check the code
@skanerkodowkreskowychqr3794
@skanerkodowkreskowychqr3794 Жыл бұрын
Is IT possibile to download all three parts? Update button doesnt work😢
@cjdrix
@cjdrix 4 жыл бұрын
Hello sir, can you help me again? When i click the data in main activity and i want to update the data, it only shows toast message no data.
@prathamchoreria5674
@prathamchoreria5674 2 жыл бұрын
any solution to this?
@HabiburRahman-xs9gb
@HabiburRahman-xs9gb 4 жыл бұрын
very helpful and well explained
@christianreydoctolero3986
@christianreydoctolero3986 2 жыл бұрын
what is the version of android studio and jdk you are using thank you?
@papermaker107
@papermaker107 2 жыл бұрын
how would you implement update if you arent using auto-incremented id's??
@shathaalnahdi4823
@shathaalnahdi4823 Жыл бұрын
Thank you so much 👍🏻
@vibhathakur5751
@vibhathakur5751 4 жыл бұрын
Is there any way to add refresh functionality by editing Android. Manifest file
@hariprasath4883
@hariprasath4883 3 жыл бұрын
Can I have two fragment class share one layout.xml file??... because both their views add and edit are same so can I reuse it?? Is it possible?
@miguelangelmunozoscategui8655
@miguelangelmunozoscategui8655 4 жыл бұрын
as the onActivityResult would do in a fragment what you explain in minute 12.18 regards
@tanmoyghosh3103
@tanmoyghosh3103 4 жыл бұрын
At 2:11 when i am going to start the new intent it is showing me an error in calling the intent...please help sir
@tanmoyghosh3103
@tanmoyghosh3103 4 жыл бұрын
Surrended with array initilisation
@kazukisenpai2405
@kazukisenpai2405 Жыл бұрын
Using arrayList may better
@MohsenMashkour
@MohsenMashkour 4 жыл бұрын
I have done everything but when i press the update button i just see the toast message and nothing is changed in the main activity.
@reshukumari4429
@reshukumari4429 4 жыл бұрын
Mine2
@alfidharmawan9115
@alfidharmawan9115 4 жыл бұрын
See at 10:41, he added new assignment for the string, based on edittext. Maybe you missed that, cause thats my problem too
@karthi-rt
@karthi-rt Жыл бұрын
I have updated data but there is no update in my data they still remains same
@gatdet
@gatdet Жыл бұрын
Any solution?
@ShakeelAhmad-sc9gv
@ShakeelAhmad-sc9gv Жыл бұрын
You can get the text from input and then update
@ShakeelAhmad-sc9gv
@ShakeelAhmad-sc9gv Жыл бұрын
If you don't get new text from input then old data will be updated... because new data is not get that is used in video.. hope you understand
@meh646
@meh646 2 жыл бұрын
My bui just speedrunning them tutorials
@puch9830
@puch9830 2 жыл бұрын
onactivityresult isnt working...any help...i work with fragmetns
@MdRakibulIslamrockpak
@MdRakibulIslamrockpak 4 жыл бұрын
Greate video, thank you
@dmitrypobedinski2255
@dmitrypobedinski2255 3 жыл бұрын
Hello. This tutorial doesn't work in 2021? A studio 2020.3.1 Jdk 11.0.10
@sohambtw
@sohambtw 2 жыл бұрын
It says no data when i click on a data to edit it
@Another0neTime
@Another0neTime 5 жыл бұрын
Excellent
@phoenixcode8034
@phoenixcode8034 4 жыл бұрын
hi Stevdza-San thank you so much for this tutorial , please make a mysql too pleaseee
@StevdzaSan
@StevdzaSan 4 жыл бұрын
Definitely in the future. Stay tuned 👍
@HyperActive94
@HyperActive94 4 жыл бұрын
lol you skipped a whole part you added in the code...
@nonetoro
@nonetoro 4 жыл бұрын
It didnt show any book information since tutorial part3, even add new book data. Anyone knows?
@curiouslamb8532
@curiouslamb8532 4 жыл бұрын
@Sahil Bhandari *Update: add this line inside the onClick method of your Add Button in the MainActivity.java startActivityForResult(intent,1);* I think the problem shows when you press back button from the smartphone navigation itself after adding new record. Pressing back button gets you back to your previous recycler view which is not updated yet. But try pressing the backbutton from the appbar and you will be redirected to an updated recyclerview content. Maybe destroying the main activity after clicking addbutton and relaunching it after clicking save button would fix it. My personal band aid solution is I created an intent in the save button which redirects to the new MainActivity that has updated recyclerview content.
@marcalestruchgarcia4568
@marcalestruchgarcia4568 3 жыл бұрын
Hey, why "pages" is initially an integer, but you are able to update it as a string on MyDatabaseHelper.java?
@mahmoudkhattab4153
@mahmoudkhattab4153 3 жыл бұрын
Dont forget at 10.42 your escape this
@h.r.60
@h.r.60 5 жыл бұрын
make a google maps api tutorial please!
@StevdzaSan
@StevdzaSan 5 жыл бұрын
I will plan that in the future
@pltsm3970
@pltsm3970 4 жыл бұрын
Hi sir On Update I just coded the same as yours When i wanna update value it Toasts me successful update but my data does not change even i Restart the app. Please help me
@aleks2147
@aleks2147 3 жыл бұрын
I think he made a mistake. Inside the onClick method of the button update you need to use the TextView.getText() method before calling myDB.updateData (...) to actually get the new updated text
@SlenderMan4466
@SlenderMan4466 3 жыл бұрын
too fast
@ramazandemir4730
@ramazandemir4730 2 жыл бұрын
when im writing this line Intent intent = new Intent(context, UpdateActivity.class); at OnClick method under CustomAdapter class i get this error: Do not treat position as fixed; only use immediately and call `holder.getAdapterPosition()` to look it up later
@FinalTie
@FinalTie Жыл бұрын
holder.mainLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(context, Update.class); intent.putExtra("id", String.valueOf(person_id.get(holder.getAdapterPosition()))); intent.putExtra("name", String.valueOf(person_name.get(holder.getAdapterPosition()))); intent.putExtra("phone", String.valueOf(person_phone.get(holder.getAdapterPosition()))); intent.putExtra("email", String.valueOf(person_email.get(holder.getAdapterPosition()))); intent.putExtra("location", String.valueOf(person_location.get(holder.getAdapterPosition()))); intent.putExtra("birthday", String.valueOf(person_birthday.get(holder.getAdapterPosition()))); intent.putExtra("hobby", String.valueOf(person_hobby.get(holder.getAdapterPosition()))); intent.putExtra("gender", String.valueOf(person_gender.get(holder.getAdapterPosition()))); } }); hey bro I have the same error can you tell me how you corrected it
@phlong10102
@phlong10102 Жыл бұрын
@@FinalTie i same bro
SQLite + Android - Delete Table Data (Book Library App) | Part 5
16:59
SQLite Backend for Beginners - Create Quick Databases with Python and SQL
13:32
Andro, ELMAN, TONI, MONA - Зари (Official Music Video)
2:50
RAAVA MUSIC
Рет қаралды 2 МЛН
Непосредственно Каха: сумка
0:53
К-Media
Рет қаралды 12 МЛН
Wednesday VS Enid: Who is The Best Mommy? #shorts
0:14
Troom Oki Toki
Рет қаралды 50 МЛН
Navigation Component - Android Studio Tutorial
12:11
Stevdza-San
Рет қаралды 181 М.
SQLite vs PostgreSQL Performance
14:01
Anton Putra
Рет қаралды 49 М.
DotNet MAUI Sqlite Tutorial - .Net MAUI Sqlite CRUD Operations
9:36
Coding Droplets
Рет қаралды 31 М.
SQLite Database for Android - Full Course
1:28:22
freeCodeCamp.org
Рет қаралды 257 М.