Complete CRUD Operation in Android Studio Java With SQL Server | ProgrammingGeek

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello viewers welcome to programming geek i'm here with a new tutorial that is complete crude operation and insert delete update charts in android studio with sql step by step [Music] [Music] okay first of all i'm gonna create a folder in dj in the android tutorial folder the name of this folder is cloud android sql okay now start android studio okay this is android studio app it's running okay now go to the file menu and click on new okay click on project new project yes now select empty activity and then click next name the application the application name is crude application and the location location is selected folder where i already created and d drive android tutorial folder the folder name is crude android ask well select ok ok and minimum sdk is 4.1 jelly bean it will support 99.8 percent okay the android project is created now go to the activitymain.xml and design this android page okay first of all edit text view yes this is the text view now add a plain text place the plain text below the text view [Music] now concentrate in of text view top left right and bottom text view and edit text plain text okay connected in left now and right now in bottom yes now place it in there paste yes same in text box plain text okay oh no yes now place it below of the text view check the text of this text view default text is text view this text view i'll use for id so text view text is id and this one for name so text is name and add another plain text and this plain text is for name and this text view is for address so change the text of this text view address and and this text box is for address okay now it's done change the id of this text view first one is for edit text id click on refactor yes it's changed now this one for edit text name [Music] and third one for edit text address okay now it's done finally add a button this button control i'll use to perform insert operation in sql server database using android studio okay now change the text of this button button text is add and button id is btn add okay refactor yes it's done my design is ready now let's run this f to see this design okay now the default text name is displaying i am removing this name text from the edit text okay it's removed now the text box is blank now add another text view to display result after performing the insert operation okay it's done this text view id is text view result effector okay and text is result now go to the activity main activity.java here i'll write code to connect sql server and then to perform insert operation to perform crude operation okay first of all suppress link new api then public connection this method will be used to connect sql server in android studio public connection connection class okay press alter plus enter yes now it's okay now connection con equal to null default connection is null now string ip i'm just declaring some variable and i'll use this and use this variable in connection string so i fee is 172.1.1.0 and four default for this one for w3 i will check it before run this application in sql server configuration manager then username username is sa this is sql server username i will show you and password password is sql server authentication password a sql servication password is program seven one okay now ddbs with database name database name is uh let's go to the sql server start sql server okay select the server name browse export database engine this is the server name and select authentication as presentation login essay and password is sql server authentication password then click on connect yes it's connected now expand the database folder and there's no database first of all create a new database database name is code android db click on ok yes the database is created and there is no table yet now i'm going to create a new table table name is i column name is id data type integer and name data type and worker address address is data dev also and parker and id is primary column so set primary key name the table table name is user info underscore tab click on ok to save yes the table is saved now replace this table folder and insert some record in the database table column okay so i'm just inserting your record record id is one zero zero and named john address is usa okay the record is inserted now my database name is crude android db so go to the android application right database name crude android db okay it's done now [Music] stick mode dot third policy tp equal to new stick mode dot that policy okay dot builder dot builder dot far metal dot build okay done now stick mode dot set third policy that's what it says tptp is third policy okay now at the trikets try at get catch exception e exception then it if it's found any exception it will display in exception as exception so log dot e error it will display the message error exception dot gun masses okay now try catch is done finally it will return the connection con okay now class dot for name double quotation then net dot source force dot jtds.jdbc dot driver that string connection url equal to jdbc colon jtds colon sql server noted that you must put the syntax accurately i am suggesting you to copy this connection string from the description box and paste it in your android application then you just change the ip port username password and database name to avoid l okay now ip then colon port and then ddb's name database name equal to variable id or database name so delivery's name yes this is the database name you can see then username username is yes so i have declared variable username so just put username user equal to username and then password [Music] password equal to password [Music] okay it's done now my connection is done [Music] finally con dot drive driver manager dot get connection connection url okay [Music] i have alright written this code for uh connect with the sql server with android studio now i'm gonna write code to far from insert operation first of all i'm gonna declaring variable for uh id [Music] edit text id a text name and it takes address so text view id equal to text viewfind paper id first break r dot id dot edit text id a text id is id of the text box and second one for name third one for address and name from edit text name our dot id dot edit text address for address okay after that button button is just declaring variable routine insert so equal to first break button find v by id r dot id dot btn at my button id is btnet okay now btn insert between insert dot set on click listener new view dot on click listener okay it's avoided public void on click it's automatically created the on click event so now connection connection equal to con class my class name is connection class name is con class connection class sorry connection class okay [Music] now edit rikets try and catch because just copy that catch from the connection class okay now catch is done now in the try if connection not equal to null i mean if connection is okay then it will perform the insert operation to far from insert operation just to write code the code is of all connection oh yes this is the connection function okay now string sql insert mysql command is insert into table name table name is user info underscore tab so put user info underscore tab then values values from id name address is i mean edit text id it takes name a text address and so id dot get text it will get from edit text id and it will insert in in the column id and user info underscore tab table okay this one for name remove the backslash yes comma then address this one for address so remove the variable name and address okay change the variable name and address now statement test equal to connection dot create statement then result set result set rs equal to st dot execute could it will execute query i mean sql statement sql insert okay now it's done go to the activitymain.xml design okay to connect to the sql you have to add jds 1.3.1.jar file in the project library so open the project open the project application and library folder just copy this jds 1.3.1 jar file and paste it in the library you can get this to download this jds file jar file go to the link in the description box below now go to the file menu and go to the project structure and then select on dependencies and click on f and then add dependencies click on jar dependency okay in the step one just uh copy the location of the jds 1.3.1.jar file directory faced yes this is the directory and put backslash to foot jts 1.3.1.0 jar file's name just copy this file name and paste it in there okay click on ok yes it's done now apply okay okay it's done now go to that android manifest expand the manifest and go to the android manifest.xml file uh i'm gonna add permission user permission android name equal to androidformation.internet and then use information android name equal to android permission dot access network state okay it's done now run the sql server configuration manager okay this is the sql server configuration manager now it's on the native client this is the tcp enable sql server configuration protocol disability is disabled must enable tcp ip yes the tcpip is enabled now and after enabling httpf you must restart the sql server so this is sql servers express let's start yes it's restarted successfully okay now run this app oh you must close this app and re-run again okay now the code is ready run this f yes please wait yes it's started let's check the records in the database table it is only one record one zero zero and the name john address usa now i'm gonna insert one more record and sql server using android studio now i'm gonna insert one more record it is one zero one id name christina and addresses canada okay click on add now oh yes application is not responding let's check the tcp port in that case go to the sql server configuration manager and sql server network configuration protocol right click and go to the properties and go to the ip address let's check the tcp ip port oh tcp ip port is three zero double six one default uh port is one four double three and uh you can check your sql server configuration manager it is vip port for actual tcp port okay now close this application and run again okay now insert a record id is 101 name christina address canada okay now click on it yes now let's check the database record yes the record inserted successfully okay now i'm gonna insert one more record one zero two name tom address canada click on it and let's check in the database table yes 102 tom and kine address scanner is inserted successfully okay [Music] now insert one more button control add one more button control this button control is used to perform update operation it will update all the data based on id that's done id okay id between update and text is update okay now for the main activity.java yes now declare the button button btn update equal to fastbreak button find view id r dot id dot beating update okay now here update button click event so between update dot set on click listener new view dot on click listener and press enter yes the on click event is created now i'm just uh coffee there connection copy the code from insert button click event yes now just paste and update button change the sql command update table name is user info underscore tab update user info underscore tab set remove the back yes now set id equal to id is database table column name column name i database table column name id name and address so id equal to single quotation double quotation plus sign idiot get text dot twisting then comma then name name is database table column name name equal to name dot get text and then address address equal to address address badges dot get text set this is variable testing okay now i have to add higher clause to update the record so just move this id set name equal to name higher id equal to higher id equal to id dot get text just remove the backslash yes id dot get text dot twisting okay okay now it's done statement st equal to connection dot create statement result set rs equal to st dot execute query run this app the app is running okay now i'm gonna update a record based on id so put id let's take the specific database table record uh okay these are the records needed to be stable 101 christina and this is canada okay now i'm gonna update to record 102 tom canada tom to ronnie and canada to india just click on update yes it's updated tom and canada now update 101 record listener to sandy and address canada to uk okay now click on update yes it's updated let's check s101 sandy and uk it's updated successfully okay now go to the activity main.xml now add one more button control to perform delete operation to delete a record based on id okay concentrate off down bottom and the left right okay now place it in there place yeah yes yes okay it's done now change the text of this button button text is delete and button id is btn delete okay now go to the main activity.java yes declare the button just copy and paste btn delete and ids id dot btn delete okay it's done now create one click listener so btn delete dot set on click listener first click [Music] new view dot on click listener okay now on click event is created just copy the code from the update button click to delete button okay now just change the sql command sql delete and then command command is delete user info underscore tab is a database table column name and remove the name and address variable and column just add her clause higher id equal to id.gettext dot twisting now use this sql delete to result set okay as to write the good query sql delete it's done around this f yes the f is running please wait okay now i'm gonna delete a record based on id so let's check the records in the sql server database table [Music] okay these are the records in the database table now i'm gonna delete id one zero one just click on delete yes it's successfully deleted let's check in the database table yes the record101 is deleted successfully now delete one zero now insert uh one more recorder based on id101 what i just deleted id name christina address uk yes it's successfully added let's check yes it's added successfully now i'm gonna update christina yes update yes successfully updated and if i click on delete it will be deleted successfully let's check yes it's successfully deleted okay insert again yes it's inserted successfully okay now it's done close this app and now i'm gonna show you how to get data now from sql server database table to text text edit text box in that case i just added a button this button controller used to get record from database table to text view edit text okay text is get and id is bdn get okay refactor yes it's done go to the main activity.java and then declare button as same as previous button work okay btn get r dot id dot btn get my button id is btn get okay now create one click listener so between get dot set on click listener fastback new view dot on click listener yes on click event is created now just copy the code from the up delete button click to get button okay now just to change the sql command sql command is select star from user info underscore tab where id equal to id dot get text not twisting okay it's done statement s t equal to connection dot q statement result set r is equal to s t dot execute okay it's done a while at a while loop while first break then rs dot next okay now i'm gonna display the result in i mean it takes id and edit text name so put [Music] still name it will display the result based on that so it uh i'm gonna show you name name dot set text rs dot get string now put index indexes id name name in index one let's check around this f okay now put id101 get it will display the name in the name text box oh it's displaying id i just mistaken the index id is one index name in index 2 address is index 3 so i have to put index 2 for name and 3 for address okay now run this app again apply change and restart okay change not apply to restart this f okay now close this f and run again yes it's running android is starting okay then now one zero zero name is john addresses uas it will display the name john energy's usb by clicking the get button yes it's successfully displaying the result in edit text box name it texts uh address if i select 1054102 is displaying running in india if i put one zero one it will display 15 and you can you can see in the stable car records okay now one day i'm gonna insert one more records 103 and with the name sandy you carried this uk okay it's inserted successfully though id103 and now i just i'm just changing the address uk to canada yes it's updated successfully you get you can add the address of id 103. okay thanks for watching this tutorial [Music] you
Info
Channel: ProgrammingGeek
Views: 4,636
Rating: undefined out of 5
Keywords: programminggeek, crud in android studio with sql, android studio tutorial, insert update delete in android studio with sql server, crud in android studio, crud in java, insert in sql using android studio, visual studio code, crud c#, android studio with java tutorial, insert update delete in android studio, connect android studio with sql, crud android studio java
Id: L4m6fQ-IX4U
Channel Id: undefined
Length: 33min 13sec (1993 seconds)
Published: Mon Jul 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.