SQL Database to Listview | Retrieve data from sql to listview in Android Studio | swift learn

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome to my channel swiftland in this tutorial i will show you how to display data from sql server database to list view in android application step by step if you don't subscribe my channel yet please subscribe and press the bell icon for upcoming videos okay go to the directory in the d jab now i'm gonna create a folder in the android project tutorial folder in this folder i will create an android application to display data in less view from sql server database to android okay now start android studio [Music] okay it's started now go to the file menu and click on new and click a new project select empty activity and click on next select the directory location where you want to create this pro project android project so yes display data in list view android select this folder and click on ok yes now name the application my application name is display data and list view from school okay click on finish yes the project is created you can see in the left fan uh this data in android sql folder okay this is mainactivity.java now go to the activitymain.xml file this is default text hello world remove this text and design this page to display data from sql server database database to list view using android okay concentrate this button and top right and left now add a list view yes this is the list view okay concentrate it with button in the top right and left bottom okay now this design is done now i'm going to create a new java class to connect with a sql server with android application in that case now my class name is connection helper connection con string ip4 db un means username db database and pass his password suppress linked new fpa okay to get the link did it public connection con class my class name is con class and i fee 172.1.0.0.4 for default port number is 1433 if you change your sql server port number you should put your sql server port number okay start sql server connect the sql server authentication login sn password resource authentication password database programming db table noise product setup underscore tab these are the records in the database table you can see product id item name design and color and database name is programming tv copy the database name and paste it in db okay now u1 is essay and pass is test 129. okay now stick mode dot third policy policy equal to new stick mode dot threat policy dot builder dot farm it all that built okay now stick mode dot set third policy policy what a declared okay now connection connection equal to default connection is null and then string connect url equal to it's also null now in the tri-catch try get sketches catch exception exception finally log dot e first break error the error message exception don't get messes okay uh press alter plus enter to service error now class dot for now for name driver okay now connection url connection url is jdbc colon jtds colon haskell server colon and double slash plus ip plus colon port colon semicolon plus ddb's name equal to db my database name is the variable of the database name is tv okay user equal to even and semicolon pass password equal to pass yes semicolon and finally it's done now connection equal to driver manager dot get connection connection url okay return connection so it's done now add jds jar dependency to add that dependency first of all you should put the jar file in your project library so to go to the project library open the app folder and open the library you can see this library folder is empty now just copy this jar file and paste it in there jtds123.jelly you can download it from internet or you can get the link to download link in the description box below okay with the project structure dependency f and click plus sign that jar dependency okay just uh select the location directory and paste yes now copy the file name file name just copy and paste it with the backslash yes click on ok ok the jar dependencies added click on apply ok yes now add permission in androidmanifest.xml this is the androidmanifest.xml file at permission under name equal to permission dot internet and another line android name call to access network state permission dot access net register okay now this is main activity java file and this is uh okay first of all i'm gonna create a layout file layout resource file yes for the file name file name should be small later okay my file name is list layout template so design this template with the text view [Music] okay now i just copy this relative layout and text view the relative layout just paste yes in this relative layout i will add text view to design this list layout template this is the text you can see it has to be productivity text view item uh product id item name i name text view colorist okay i just uh for t text view let's go select and copy and go to the android layout template yes all right added you can see text product id i name design and color okay id item name design and color and the product is protected the item name is i name design is ds color sql okay now you can see the layout to write off and layout to write your product id and text view design will be the right of product id and this is below of description okay now add a java class yes new java class class name list item and this list item just vote connection connect string connection result equal to default connection result is blank now boolean is success equal to false initially the subsequent false finally it will be true okay now public list map and then string string this is get list okay list map string string data equal to null initially declare data is null now data equal to new error list and it will be mapped string string try connection helper function alpha equal to neo connection helper connection alpha is my java class what i [Music] used to connect to the as possible database okay if connect equal to null then [Music] it will display the not equal to null i mean if connection is okay then string q u equal to given english query select start from products unless the set of underscore type the database table then statement statement equal to connect.create statement [Music] final result set result set equal to statement dot execute query q u uh add uh just a fresh alter shift and enter it results are okay now while result set down next [Music] okay [Music] map string string dt name equal to new hash map string string okay dt name dot port product id text view id is product id result set dot cat string column level product underscore this is database and column name product underscore id item name design and color okay [Music] now copy this line of code and face for item name design and color i name the text view id see that my name is text view id and design and colors ds and cell call so item name d s and c l and this is column level is from the database table column column name item name design and color let's see item name design and color in the sql separate database table okay now data data dt name semicolon yes connection result equal to success is success equal to true okay finally connect dot close and close closing the connection else connection result equal to failed okay uh get list written oh yes we should return the data equal to data now in the main activity activity main java are just creating a method public board got list view b list view lsd this is declaring variable it has to be equal to list view find viva id r dot id dot list view my list view name is oh yes i have to write the id this is button okay and let's be your ids list view one okay id list view one so for list view one id dot list new one okay now call this method leave list map string string my data list equal to null okay now list item my data equal to oh yes new list item my data list equal to my data dot get list this is my method name string from w this is from where now just put [Music] text view id product id i name ds and cl [Music] okay now in desire2w equal to r dot id dot product id r dot id dot [Music] i name r dot id dot d s another id dot c l okay now simple adapter addy so [Music] i just declared the simple adapter id now add equal to new simple adapter selector is main activity dot this my data list data and r dot layout dot is my layout name list layout template you can see what lag template i added and then from wn2w okay now lsd view dot set adapter eddy okay now it's done let's check the very veda tcp ip is enabled from sql configuration manager this is the special configuration manager tcpap is enabled and sql server network configuration click on protocols tcp ip enable yes the tpf is enabled if you change the tcp you must restart the sql server service okay now change the text color of this product id and item name okay let's always use code color code instead of color name [Music] okay it's running just click on load data yes you can see 100 ram dell new version is displaying perfectly thanks for watching this tutorial you
Info
Channel: Swift Learn
Views: 11,182
Rating: undefined out of 5
Keywords: swift learn, sql database to listview, android studio, display data from sql to listview, retrive data from sql to listview, sql to listview in android, listview in android, sql to listview, load data from sql to listview in android, android tutorial
Id: pe0GmXHAda4
Channel Id: undefined
Length: 18min 46sec (1126 seconds)
Published: Sat Jan 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.