Тёмный

SQLite + Android - Insert Data in Database Table (Book Library App) | Part 2 

Stevdza-San
Подписаться 83 тыс.
Просмотров 133 тыс.
50% 1

🏆 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/stevdza-san/SQLite...
Part 1 (Create Database Schema) - • SQLite + Android - Cre...
----------
Part 3 (Display Data in Recyclerview) - • SQLite + Android - Dis...
Part 4 (Update Table Data) - • SQLite + Android - Upd...
Part 5 (Delete Table Data) - • SQLite + Android - Del...
Part 6 (Animate Recyclerview Items) - • 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.

Опубликовано:

 

12 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 140   
@dmytroazhdier2311
@dmytroazhdier2311 4 года назад
Thanks for your time! This video was helpful to me :-)
@user-yl1bx2df7g
@user-yl1bx2df7g Год назад
You are the best kotlin Shifu that I have ever listent to. Thank you very much😘
@sinoiumarzoda7857
@sinoiumarzoda7857 3 года назад
Thank you a lot, I like the way you explaining.
@user-zn4vc4kn5l
@user-zn4vc4kn5l 11 месяцев назад
شكرا جزيلا .. لقد استفدت كثير..
@skanerkodowkreskowychqr3794
@skanerkodowkreskowychqr3794 5 месяцев назад
Thank You. Very Useful video
@willemsmit2929
@willemsmit2929 3 года назад
Thank you helped a lot!
@anastasiosarvanitis9533
@anastasiosarvanitis9533 3 года назад
Thank you so much, your tutorial is amazing, I will be checking your udemy courses ;)
@sandrokhoshtaria9923
@sandrokhoshtaria9923 4 года назад
Very good videos. Keep it up!
@Tu_Calisthenics
@Tu_Calisthenics 2 года назад
Thank you so much, i'm learn very much from you! :))
@deveshsingh4214
@deveshsingh4214 3 года назад
Thank you very helpful.
@fral.2708
@fral.2708 Год назад
Thank you very much for this! Just a question: to export the databases every time is the only way to see the datas with SQLite-Studio? It is a bit cumbersome. Maybe there is some extension for Android Studio to see the datas directly on the IDE?
@BrianMaia
@BrianMaia 4 года назад
Thank you very much! You helped me a lot.
@dominikkajba8766
@dominikkajba8766 3 года назад
Brate legenda si
@hassanalighumman1473
@hassanalighumman1473 2 года назад
Love from Pakistan bro. Great video series.
@kostiasavchenko7742
@kostiasavchenko7742 Год назад
Thank's a lot. It works :)
@shaheershukri
@shaheershukri 3 года назад
if i wanna add some column in database.. where do i need to modified my code?
@umangkosrekar4788
@umangkosrekar4788 2 года назад
i m getting and error of "E/RecyclerView: No adapter attached; skipping layout" can anyone help
@coderinmood5119
@coderinmood5119 2 года назад
Awesome Video
@nasrullahsafdari
@nasrullahsafdari Год назад
Thanks for the video, but I have a question, what if we want to create two tables? How we can do it? I tried several times but the second table was not created? Thanks
@ifatou
@ifatou 3 месяца назад
👏👏👏👏 espectacular
@laziboi5975
@laziboi5975 2 года назад
I like how he explain the code 😁
@tusharchavan668
@tusharchavan668 4 года назад
Hii After Clicking On Item in recyclerview again there is one recyclerview inside it and I have to create table for it in same database but the name of the table is first recyclerview item name how can I?
@rubenoganesyan1669
@rubenoganesyan1669 4 года назад
Thx a lot.
@gilmarcossantos3951
@gilmarcossantos3951 2 года назад
Muito obrigado!
@user-ey6hz4us3s
@user-ey6hz4us3s Месяц назад
when i went to file explore and to data - data , i did not find my file project and it shows error to the over files that said the package not debuggable .!!!!!!!!
@puch9830
@puch9830 2 года назад
i have login and register page, how do i create crud along with login?how do i put them in one db...i keep having problems on every step
@abdulrehmanalibrohi221
@abdulrehmanalibrohi221 Год назад
will you please tell me in backend you will use java or kotlin?
@hapham7098
@hapham7098 3 года назад
thank youuuu
@andhikapratama345
@andhikapratama345 2 года назад
You are amazing
@naznazanavc7780
@naznazanavc7780 3 года назад
magnificent
@niphomahlangu2733
@niphomahlangu2733 2 года назад
Thank you. 👏🔥👏🔥👏
@StevdzaSan
@StevdzaSan 2 года назад
You're welcome 👊
@kghoxbulah465
@kghoxbulah465 4 года назад
Thanks
@amandasjoberg463
@amandasjoberg463 10 дней назад
I am struggling with how to avoid opening and closing the database multiple times, because I read that best practise is to open it once when starting the app and to close it once when closing the app. I also read that is recommended to have the dbhelper as a singleton. I have several viewmodels that access the database through the database helper and I'm finding it difficult to put all of this together... how do I open it once if I need both a writable and readable db? Also, the context that is passed, is it the activity or fragment? I have one activity and several fragments which in turn have their own view models. Currently all viewmodels create a new dB helper and each method in the dBhelper class opens and closes the dB. I'm real,y struggling with architecture... Anybody got any tips?
@playtoy_cardi_7201
@playtoy_cardi_7201 Месяц назад
what if i want to insert an image of the book also, can ou explain pls or make a video with this app and code?
@AbdulBasit-yf8xv
@AbdulBasit-yf8xv 3 года назад
Can you make a video about foreign key insertion as well..
@RealOny
@RealOny 3 года назад
My application keeps crashing upon clicking on the add button, try catch yielded no results and kept crashing.
@majinzeke4977
@majinzeke4977 3 года назад
Same. I need help!
@jemmytech5474
@jemmytech5474 3 года назад
Same, I need help
@aimilios4794
@aimilios4794 3 года назад
Same but i fix it after crying 2 hours above the keyboard. Open the github link in the description of the video and check line by line the Database helper. In my case i forgot to add the following line "this.context = context;" in the constructor of the Database Helper class. Hopefully this will help you!
@bernardolaborde5310
@bernardolaborde5310 3 года назад
The problem was the space in the query before (" + COLUMN_ID + "INTEGER PRIMARY KEY AUTOINCREMENT, " +" after "" (" + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +" You have to space in the begining of Interger
@xavispartan117
@xavispartan117 3 года назад
i had the same issue, i put as comment the Toast line in the else statement in the MyDataBaseHelper class before: } else { Toast.makeText(context, "¡Venta Guardada!", Toast.LENGTH_LONG).show(); } after: } else { /*Toast.makeText(context, "¡Venta Guardada!", Toast.LENGTH_LONG).show();*/ } it worked for me, you can try it
@pandakaradi4959
@pandakaradi4959 3 года назад
how to add images too with this!
@zaidtahir936
@zaidtahir936 Год назад
I am doing same like as but my Toast show "Failed" guide me ?
@sakshamvasudev1645
@sakshamvasudev1645 Год назад
we can see database through app inspection as well
@minhnguyendang8900
@minhnguyendang8900 3 года назад
How to update recycleview after insert data ?
@tastystreetfood9
@tastystreetfood9 10 месяцев назад
Anyone please helps me, I dont have the purple navigation bar as above. How can I make it. I didnt see Stevdza created it. Please help!!!
@michaelvalentino9141
@michaelvalentino9141 Год назад
What application that you use to create android application?
@ravanelmochamad
@ravanelmochamad 2 года назад
7:49 I don't have the databases, help please
@zawhninthet843
@zawhninthet843 Год назад
me too; if u r ok help me pls
@eldomart
@eldomart 24 дня назад
try File-Invalidate caches-Clear VCS Log Caches and Indexes->Invalidate and Restart, it will restart and start from building Gradle again, the Persistent Database should show up in the Device File Explorer by itself without us having to start the App at all.
@jakubdura8452
@jakubdura8452 Год назад
U can use database inspector to show db :D
@amnakhalil5587
@amnakhalil5587 3 года назад
it's throwing null pointer exception as i click to add ........Is there anyone to help me?
@majinzeke4977
@majinzeke4977 3 года назад
I need help with this too!!! Please
@tqaquotes9379
@tqaquotes9379 5 месяцев назад
I have problem in settings the emulator, can anybody help?
@seifabdihafid681
@seifabdihafid681 2 года назад
I keep getting failed 😞 when I click at the add button on my add activity class
@rubinho388
@rubinho388 2 года назад
did you get why it was getting failed? I'm with the same problem
@seifabdihafid681
@seifabdihafid681 2 года назад
@@rubinho388 yeah I was able to after a few trials thanks
@baraaksarihabiles5954
@baraaksarihabiles5954 2 года назад
@@seifabdihafid681 can you tell me what did you do please..I have the same problem
@jimbotron2
@jimbotron2 Год назад
@@baraaksarihabiles5954 I fixed it by changing the DATABASE_VERSION to 2 instead of 1
@user-to6vi7dm2z
@user-to6vi7dm2z Год назад
When I add the data the message tell me not added where is the mistake
@dilnamo
@dilnamo 7 месяцев назад
Hello, Can you help me? I wrote your code in my Android studio, but it is showing only Failed?
@bahrifaten8672
@bahrifaten8672 2 месяца назад
Same here U find a solution
@ampa4989
@ampa4989 3 года назад
The video is helpful, but that dracula mode is a bit difficult to discern.
@jenniesloft9225
@jenniesloft9225 2 года назад
I have two titles inside of database file not three and it doesn't open by sqllite
@user-sk1wi7co7c
@user-sk1wi7co7c Год назад
do you have an answer to this?
@eldomart
@eldomart 24 дня назад
try File-Invalidate caches-Clear VCS Log Caches and Indexes->Invalidate and Restart, it will restart and start from building Gradle again, the Persistent Database should show up in the Device File Explorer by itself without us having to start the App at all.
@gamesforu6619
@gamesforu6619 Год назад
Can I save object in database instead of multiple variables as you did?
@mannb1023
@mannb1023 Год назад
no, sql is not an object oriented language. If you want to store objects maybe a noSql language can do it? But I doubt that too
@harshithas9410
@harshithas9410 3 года назад
I'm getting like duplicate resources how to solve it
@wheepup8452
@wheepup8452 2 года назад
the database folder does not appear in the File Explorer. I followed the correct path. It says that "run-as:/data has wrong owner: 0/1000, not 100" Please help
@eldomart
@eldomart 24 дня назад
try File-Invalidate caches-Clear VCS Log Caches and Indexes->Invalidate and Restart, it will restart and start from building Gradle again, the Persistent Database should show up in the Device File Explorer by itself without us having to start the App at all.
@shashanksp9168
@shashanksp9168 2 года назад
DB NAMES OF bookauthor is taking as book_authorTEXT , and same folows for the title please help here's my code String query ="CREATE TABLE " + TABLE_NAME + " (" + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_TITLE + " TEXT ," + COLUMN_AUTHOR + " TEXT," + COLUMN_PAGES + " INTEGER );"; after creation of table it shows book_authorTEXT and book_titleTEXT together in database
@shashanksp9168
@shashanksp9168 2 года назад
I'm not getting a space between book_author and TEXT in the create code too..
@pankajwandre5961
@pankajwandre5961 4 года назад
👍👍👍👍
@sammybelete4711
@sammybelete4711 Год назад
how you guy found three files inside ur /data/data/project_name/database file, which android studio version are you using... i only got one file and i coded exactly in program and it create the table and don't even insert texts inside my rows...
@eldomart
@eldomart 24 дня назад
try File-Invalidate caches-Clear VCS Log Caches and Indexes->Invalidate and Restart, it will restart and start from building Gradle again, the Persistent Database should show up in the Device File Explorer by itself without us having to start the App at all.
@johnohnitmartinez907
@johnohnitmartinez907 2 года назад
Can sqlite can be realtime ?
@leandrocoelhinho
@leandrocoelhinho 3 года назад
muito bom, parabéns
@pandakaradi4959
@pandakaradi4959 3 года назад
How to store images insql
@GeorgeR-dt4yu
@GeorgeR-dt4yu 2 года назад
There were errors downloading files and/or directories: Writing local file failed! when saving sqlite
@shashanksp9168
@shashanksp9168 2 года назад
first close the database opened in the sqlbrowser and retry saving .
@jayperson2239
@jayperson2239 Год назад
7:47 there is no sqlitetutorial files in my device file explorer. can u help me about this?
@zaidtahir936
@zaidtahir936 Год назад
Bro same did you solve that problem?
@lanzmanlapaz
@lanzmanlapaz Год назад
same here
@eldomart
@eldomart 24 дня назад
try File-Invalidate caches-Clear VCS Log Caches and Indexes->Invalidate and Restart, it will restart and start from building Gradle again, the Persistent Database should show up in the Device File Explorer by itself without us having to start the App at all.
@hyno
@hyno Год назад
#DONE
@christianjosephdimla4708
@christianjosephdimla4708 3 года назад
Any fix for BookLibrary keep stopping. Every time i put some data it always says Booklibrary keep stopping. Thankyou in advanced
@StevdzaSan
@StevdzaSan 3 года назад
Switch to ROOM Library
@a_36_atharvathosar11
@a_36_atharvathosar11 2 года назад
The error comes because of the else statement in the addBook() function. I Don't know the reason but I worked my way to the conclusion through debugging.
@a_36_atharvathosar11
@a_36_atharvathosar11 2 года назад
For me, this.context = context statement was missing in the constructor. Fixing that fixed the issue for me.
@ricetech1396
@ricetech1396 Год назад
@@a_36_atharvathosar11 hey, how exactly did you fix that cus I am having de same issue
@kghoxbulah465
@kghoxbulah465 4 года назад
How to do it Click on the title to transfer data Another activity displays the title and content
@bernardolaborde5310
@bernardolaborde5310 3 года назад
The problem was the space in the query before (" + COLUMN_ID + "INTEGER PRIMARY KEY AUTOINCREMENT, " +" after "" (" + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +" You have to space in the begining of Interger
@codingwithme3794
@codingwithme3794 3 года назад
Yes, true, but for me, I did not find a database file to choose the Book.db file to display on db browser for sqlite. What is the problem?
@StevdzaSan
@StevdzaSan 3 года назад
Make sure you opened a right app path.
@codingwithme3794
@codingwithme3794 3 года назад
@@StevdzaSan The problem has been resolved and now I want to display a link but there is a problem when it displays in db browser for sqlite it displays like this: Landroid.text.style.URLSpan; @ 7cc9ba How do I display the link correctly in db browset for sqlite and in programming when using recyclerview I will display the image from the link Is this idea correct in the sense will it be displayed through the link Can you help me?
@onepath8122
@onepath8122 3 года назад
@@codingwithme3794 how you solved the previous issue?
@zawhninthet843
@zawhninthet843 Год назад
how u resolve the previous problem
@eldomart
@eldomart 24 дня назад
try File-Invalidate caches-Clear VCS Log Caches and Indexes->Invalidate and Restart, it will restart and start from building Gradle again, the Persistent Database should show up in the Device File Explorer by itself without us having to start the App at all.
@majinzeke4977
@majinzeke4977 3 года назад
When I click on the add button, my app crashed. Do you guys might know why?
@majinzeke4977
@majinzeke4977 3 года назад
I got it to work
@jemmytech5474
@jemmytech5474 3 года назад
@@majinzeke4977 could you tell me bro, how
@jemmytech5474
@jemmytech5474 3 года назад
Problem solved. +923345850933 contact me to share the code.
@jemmytech5474
@jemmytech5474 3 года назад
Thank you dear stackoverflow
@wafaab1688
@wafaab1688 3 года назад
how did you resolve the problem ??
@TheEasyNotes
@TheEasyNotes 4 года назад
i m wating for the 3rd part/please hurry up
@kamadjesadjiedjienaallen8433
@kamadjesadjiedjienaallen8433 4 года назад
don't you know how to say pls.....
@jemmytech5474
@jemmytech5474 3 года назад
Bro my app crashes after clicking add button
@TiTaNFury
@TiTaNFury 2 года назад
@@jemmytech5474 you got solution?
@jham6676
@jham6676 2 года назад
why it is failed
@adityaverma3832
@adityaverma3832 4 года назад
i can't call mydatabasehelper object in mainactivity can anyone help me
@akarthickdinesh3426
@akarthickdinesh3426 4 года назад
Whats the error
@chimerakraken
@chimerakraken 3 года назад
make it public
@Schnovak
@Schnovak 2 месяца назад
4:03
@vikassingh1801
@vikassingh1801 4 года назад
Bro Integer value is not storing in database my app crashes everytime but string value are getting stored perfectly... Plss help
@AhmedMostafa-so2jp
@AhmedMostafa-so2jp 3 года назад
i got the same problem, have you fixed it?
@jemmytech5474
@jemmytech5474 3 года назад
Why he doesn't response to anyone?
@bernardolaborde5310
@bernardolaborde5310 3 года назад
The problem was the space in the query before (" + COLUMN_ID + "INTEGER PRIMARY KEY AUTOINCREMENT, " +" after "" (" + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +" You have to space in the begining of Interger
@bahrifaten8672
@bahrifaten8672 2 месяца назад
It doesn't work it's Always shows failed
@namanagarwal3831
@namanagarwal3831 3 года назад
Tutorials awesome but one thing is going wrong when I rotate phone from portate to landscape recycling view not showing any data how to fix it portate mode working fine 🙄
@yishakwondim6698
@yishakwondim6698 3 года назад
you have to create another xml file for landscape mode
@moataz2415
@moataz2415 3 года назад
always give me failed after all of that , short sad story
@jham6676
@jham6676 2 года назад
same
@seifabdihafid681
@seifabdihafid681 2 года назад
Were able to fix this issue
@zaidtahir936
@zaidtahir936 Год назад
same
@anohene1
@anohene1 4 года назад
Can you do a video of this in Kotlin too?
@StevdzaSan
@StevdzaSan 4 года назад
I started creating kotlin tutorials for beginners. There will be an advanced topics in the future as well
@anohene1
@anohene1 4 года назад
@@StevdzaSan Sure. I'll wait for that. Thanks
@ntry6429
@ntry6429 2 года назад
db.execSQL("DROP TABLE IF EXISTS" + TABLE_NAME); _EXISTS_ is Error in my program..
@ricetech1396
@ricetech1396 Год назад
@ntry Try out adding space after EXISTS
Далее
БЕСКОНЕЧНАЯ ВОДА . ФОКУС
00:34
Просмотров 152 тыс.
Everything you need to know about Kotlin 2.0 🟣
11:05
Solving one of PostgreSQL's biggest weaknesses.
17:12
Просмотров 173 тыс.
Apple Is Joining The AI Cash Grab
9:50
Просмотров 29 тыс.
Rest API - Best Practices - Design
15:50
Просмотров 96 тыс.