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

  Рет қаралды 66,768

ProgrammingGeek

ProgrammingGeek

3 жыл бұрын

Learn Complete CRUD Operation in Android Studio Java with SQL Server. This tutorial teaches you how to perform Complete CRUD Operation in SQL using android studio with Java step by step. Usually, CRUD operation is most basic concept in all programming. So, this tutorial CRUD operation in android is important for a programmer and helpful as well. We create asp.net application to manage an organization. But sometime some client demand that they need android application as same as the feature of ASP. Net web application. That's why I have created this tutorial.
Just follow these steps-
1. Create a new android application.
2. Design the android page with TextView, editTextName and button control.
3. Create database and table in SQL Server.
4. Connect SQL server with android studio.
5. Write code to execute CRUD operation in android studio with SQL.
Prerequisites.
You should have installed SQL server and android studio with JDK and SDK. You can use SQL server integrated with visual studio instead of SQL Server management studio.
To download .jtds file go to this link
drive.google.com/file/d/1GKf8...
This tutorial also covered-
1. Creating new android app in android studio.
2. Creating SQL server database and table in SQL server.
3. Creating class in java to connect SQL server database with android studio.
4. Place the SQL Server database details to the connectionURL in connection class.
5. Using the class in button OnClickListener.
9. Finally write code in each button click event to perform CRUD operation in android studio with SQL server step by step.
Noted that you must have enabled TCP/IP in SQL Server. If you change TCP/IP you must restart SQL Server Service.
@SuppressLint("NewApi")
public Connection connectionclass() {
Connection con = null;
String ip = "172.1.0.1", port = "1433", username = "sa", password = "row@129", databasename = "CRUDAndroidDB";
StrictMode.ThreadPolicy tp = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(tp);
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
String connectionUrl = "jdbc:jtds:sqlserver://" + ip + ":" + port + ";databasename=" + databasename + ";User=" + username + ";password=" + password + ";";
con = DriverManager.getConnection(connectionUrl);
} catch (Exception exception) {
Log.e("Error", exception.getMessage());
}
return con;
}
-- Code in onCreate event
TextView id = (TextView) findViewById(R.id.edittexid);
TextView name = (TextView) findViewById(R.id.edittextname);
TextView address = (TextView) findViewById(R.id.edittextaddress);
Button btninsert = (Button) findViewById(R.id.btnadd);
Button btnupdate = (Button) findViewById(R.id.btnupdate);
Button btndelete = (Button) findViewById(R.id.btndelete);
Button btnget = (Button) findViewById(R.id.btnget);
btninsert.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Connection connection = connectionclass();
try {
if (connection != null) {
String sqlinsert = "Insert into UserInfo_Tab values ('" + id.getText().toString() + "','" + name.getText().toString() + "','" + address.getText().toString() + "')";
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery(sqlinsert);
}
} catch (Exception exception) {
Log.e("Error", exception.getMessage());
}
}
});
Visit my page in Facebook
/ programminggeek7
------
More Tags
#CompleteCRUDOperationInAndroidStudioWithSQL #CRUDInAndroidStudio #InsertDeleteUpdateSearchInAndroidStudioWithSQL #CRUDInSQLAndroidStudio #CrudOperationAndroid
programminggeek,crud in android studio with sql,android studio tutorial,insert update delete in android studio with sql server,crud in android studio,insert in sql using android studio,connect android studio with sql,crud android studio java,crud operation android studio in sql with java,crud android studio,crud in sql using android studio,crud,java,crud in sql,crud in android,android studio crud,android crud,android crud tutorial,android crud example

Пікірлер: 82
@nizamuddin4128
@nizamuddin4128 3 жыл бұрын
Many many thanks sir. After a long time I have found such helpful tutorial. Thanks again.
@ProgrammingGeek
@ProgrammingGeek 3 жыл бұрын
Pleased to see your comment. Thanks.
@isabellafrancine1287
@isabellafrancine1287 2 жыл бұрын
thank you so much
@mrreese2342
@mrreese2342 Жыл бұрын
The way you say "Oooow" is kinda adorable lol :) thanks for the tutorial really helps
@ProgrammingGeek
@ProgrammingGeek 19 күн бұрын
So kind of you. Please keep connected.
@briankipkoros1387
@briankipkoros1387 2 жыл бұрын
Thank you so much man you are a lifesaver
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Thanks for your valuable comments.
@juliosolis6255
@juliosolis6255 2 жыл бұрын
Excelente muy bien explicado, muchas gracias!
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Thanks for your comment. Please keep connected.
@erwen1kad682
@erwen1kad682 2 жыл бұрын
thank you so much sir
@loubnaelbachari5754
@loubnaelbachari5754 2 жыл бұрын
so many thanks for you i have found it so helpful
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Thank you too for your valuable comment. Please keep in touch.
@JoseMartinez-hj9tt
@JoseMartinez-hj9tt 3 ай бұрын
Thanks man!!
@ProgrammingGeek
@ProgrammingGeek 2 ай бұрын
Happy to help!
@dhakshnamoorthy8673
@dhakshnamoorthy8673 2 жыл бұрын
Hi bro I'm developing an online bingo app in android studio where the user is ready to play the server should find the opponent for it and start the match . For that what should I do or what online server should I choose pls guide me .
@SKpro52
@SKpro52 Жыл бұрын
If I create multiple screens and only execute the connection function on Mainactivity, will the database be accessible from other activities?
@MeFiStArmaliteTV
@MeFiStArmaliteTV 2 жыл бұрын
It is possible to do the same but using PostgreSQL database instead of SQL Server?
@rezanurdiyanto9167
@rezanurdiyanto9167 3 жыл бұрын
Good, thankz
@ProgrammingGeek
@ProgrammingGeek 3 жыл бұрын
Thank you too for your valuable comment. Please keep in touch.
@brygerrodriguez3458
@brygerrodriguez3458 Жыл бұрын
could you do the same with azure data base? so far there is no one to show it on video
@andreaberge6956
@andreaberge6956 2 жыл бұрын
I am connected to the database and can select values, but insert and update won't work.. do you know what could be the problem?
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
check the full code. at the ending watch data.add portion. hope you will success. Thanks.
@gneytalha
@gneytalha 9 ай бұрын
Hello sir, I am trying to program android, but it is very difficult to find resources. Can I ask you a question, especially regarding SQL server transactions? Do you have any ideas on how I can get the total values ​​of records between 2 dates?
@Jeanto21
@Jeanto21 2 жыл бұрын
If anyone has any problems connecting to the database. I tried to add a new firewall rule with port 1433, this is what worked for me.
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Thanks for your comment
@nurulhaiderhridoy1551
@nurulhaiderhridoy1551 Жыл бұрын
Hi sir , I haven't any error but after i inserted any value in android studio it is not inserting in Database. please Help me sir.
@brygerrodriguez3458
@brygerrodriguez3458 Жыл бұрын
Do you have an example of how to connect with Azure?
@nguyenleconghauit
@nguyenleconghauit 2 жыл бұрын
Thanks man. This video so great that you have show data from SQL to textview in app Android. But now 09/ 2021, I have try many way, it really not workings that when I click button, no event listener appears.And I have connect check login from android to sql but it not working. Can you help me? Can I have link your Facebook to ask you? Thanks you a lot, I will be grateful you. Hope you reply my answer.
@christopherchua3997
@christopherchua3997 2 жыл бұрын
Hi, is it possible to accept null values for the CRUD Operation?
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Please try.
@user-oi5fz5el1v
@user-oi5fz5el1v 2 жыл бұрын
Is there any other thing needed to connect to database I have done all the things in this video but my connection have not been setup maybe u can help...!!
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Check your SQL Server port no. Default port no is 1433. If it change in your sql server then put that one. to get port no- go to SQL Server Configuration manager. right click on the TCP/IP and go to the Property scroll down and see the port no. Thanks
@daniworraodaa949
@daniworraodaa949 2 жыл бұрын
how can i get your source code ...but you did it everything thank you al ot
@Febrianian
@Febrianian 2 жыл бұрын
Thanks for this tutorial, Login user into app please ...
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Thanks for your comment. I will
@ivandaming1995
@ivandaming1995 Жыл бұрын
hello! how to code that if I use xammp phpmyadmin
@mydreamer2023
@mydreamer2023 2 жыл бұрын
I receive this error Network error IOException: Connection refused
@phuongngaphan2525
@phuongngaphan2525 2 жыл бұрын
Hello friend. I already have a database on hosting and how can I connect to it. Please help me
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Thanks for your question. You may use real ip instead of local ip. I will make such tutorial very soon. Please wait
@Qu3sti0nX
@Qu3sti0nX 2 жыл бұрын
Hello. First of all, thank you for this tutorial. It helped a lot! Thanks. On the second hand: Could you help me with, what should I do to connect my local database from a real device? I always get "connection refused" error. I know it could be the firewall, but can you help me, how could I allow the connection?
@rivaldovola9896
@rivaldovola9896 2 жыл бұрын
i have the same problem please help
@Qu3sti0nX
@Qu3sti0nX 2 жыл бұрын
@@rivaldovola9896 I've found the solution. :) 1.) Go to the Control Panel 2.) Go to System and Security 3.) Go to Windows Firewall 4.) Now go to Advanced Settings Okay now you should import new policies for inbound and outbound rules. 1.) Select Inbound rules 2.) Click New Rule 3.) Select Port and then Next 4.) Now give your port which was 1433. 5.) Now press Next until you reach the final chapter. 6.) Give a name for the rule. (It can be anything) Okay, the inbound rule is done. Now you need to do the very same thing with outbound rule. Just be "careful" at the chapter named Action select the "Allow all Connection" option. I hope it helps :D
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Thanks
@patd7352
@patd7352 2 жыл бұрын
I struggled with getting my physical phone to work, but finally got it to work when I enabled port forwarding on the *router's* 'firewall status' section (to my laptop within the router's LAN) as well as on my laptop's firewall (laptop is on a Home WIFI), to make port 1433 open on my laptop's IP address. Hope this helps someone struggling with this.
@Digital-Chetan
@Digital-Chetan 7 ай бұрын
I am facing same problem how can I resolve it @@patd7352
@mrreese2342
@mrreese2342 Жыл бұрын
Quick question, if i build the app on my phone and disconnect phone from PC, will the database be accessed and how ?
@OffYourFeet
@OffYourFeet Ай бұрын
Late response but the answer is yes. The mobile phone and the laptop you are using are both needed to be in the same connection. To connect them to each other, you may use a single internet provider or just connect your phone through the mobile hotspot of your laptop.
@bh7066
@bh7066 2 жыл бұрын
E/Error: The executeQuery method must return a result set.
@harisulislam6302
@harisulislam6302 2 жыл бұрын
I have develop water application which is run on localhost sql server. If install apk directly the conection string is working successfully that means i can login. But if i install apk via play store i can not login. Can any one help me about this. Please please
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Try with real ip instead of local ip. Thanks
@muhammadsyafie4248
@muhammadsyafie4248 2 жыл бұрын
currently having E/error: net.sourceforge.jdts.jdbc.Driver, any idea?
@dummysecond2787
@dummysecond2787 2 жыл бұрын
same, did you fix yours? how did you fixed? can you share it. Pls
@muhammadsyafie4248
@muhammadsyafie4248 2 жыл бұрын
@@dummysecond2787 done, i already fixed mine. share to me ur email i sent the code for the db connection
@dummysecond2787
@dummysecond2787 2 жыл бұрын
@@muhammadsyafie4248 (second dummy0) my g-mail acc. No spacing. I comment so many times but always deleted :(
@dummysecond2787
@dummysecond2787 2 жыл бұрын
@@muhammadsyafie4248 send me your email too. I will message u thank youu!
@muhammadsyafie4248
@muhammadsyafie4248 2 жыл бұрын
@@dummysecond2787 done email, just replace ur main activity file
@johnclarklabasan2110
@johnclarklabasan2110 2 жыл бұрын
Thanks, is this also working Xmap?
@johnclarklabasan2110
@johnclarklabasan2110 2 жыл бұрын
I have tried this on Xamp and it doesn't work huhu
@RohitK10
@RohitK10 Жыл бұрын
Can I search data by I'd? Plz reply
@ProgrammingGeek
@ProgrammingGeek Жыл бұрын
Sure, you can. watch this tutorial kzfaq.info/get/bejne/Y9yTlJypxMqWaIk.html
@technosmart2435
@technosmart2435 2 жыл бұрын
Very helpful bt. But how can I call procedure, function ,from sql server instead of writing query in android studio . Please help me.
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Good idea. I will make such tutorial very soon. Thanks
@technosmart2435
@technosmart2435 2 жыл бұрын
@@ProgrammingGeekI'm waiting .. I'm waiting . I want use SQL server with android completely. I'm web developer .Use .Net c# with SQL server. So I want my web application in android using SQL data Base. Please make video. Thnx for responding
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
@@technosmart2435 Thank you too to be connected with me.
@leminhthang7898
@leminhthang7898 Жыл бұрын
You can do a complete project on human resource management android app connected to sql server. And has all the functions. Combined with RadioButton, Switch, Date May. I really need them. Please! I am an amateur.
@leminhthang7898
@leminhthang7898 Жыл бұрын
And maybe County, district. Retrieved from database for selection in insert.
@ibrahimalmesbahi754
@ibrahimalmesbahi754 Жыл бұрын
how to make the android app with sql server work offline such as whatsapp
@ProgrammingGeek
@ProgrammingGeek Жыл бұрын
host the database and put real ip in connectionstring. thanks.
@ibrahimalmesbahi754
@ibrahimalmesbahi754 Жыл бұрын
@@ProgrammingGeek I have hosted Sql Server database and i can connect to it normally . now i need to create SQLite as local database and make sync between SQLite and remote sql server in android studio
@markcruz3008
@markcruz3008 3 жыл бұрын
Hi Programming Geek, I want to know if we can use the Server Name rather than the IP Address to connect to SQL Server? Your reply would be really appreciated. Thank you!
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Hello genius, Please try yourself and let me know. thanks🌷🌷
@markcruz3008
@markcruz3008 2 жыл бұрын
I've already tried it but no success. Already found another solution for my problem. Btw, thank you for replying.
@user-jr8py9gw9w
@user-jr8py9gw9w 9 ай бұрын
pls code file activity_main.xml
@easypc1913
@easypc1913 6 ай бұрын
hello Send me a link github
@rajatx4823
@rajatx4823 2 жыл бұрын
Does not work sir
@ProgrammingGeek
@ProgrammingGeek 2 жыл бұрын
Check your connectionstring. you can copy from description box. Check you SQL Server Port no. thanks
@namikazeminato68
@namikazeminato68 Жыл бұрын
Hey man! I loved the video and found it very helpful, But there is one problem, I do not know how to find the ip address of the server, can you please tell me how to find the ip address of the sql server? Thanks in advance
@ProgrammingGeek
@ProgrammingGeek Жыл бұрын
IP address is in PCs, if your computer is in local network, you must have an IP Address. To get IP address of the server go to the ethernet settings. double click on LAN icon. You can use SQL server name instead of IP Address. Thanks.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 101 МЛН
Clown takes blame for missing candy 🍬🤣 #shorts
00:49
Yoeslan
Рет қаралды 49 МЛН
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,8 МЛН
Java Database Connectivity | JDBC
20:34
Telusko
Рет қаралды 246 М.
SQLite | 01 ListView & CRUD | Android Studio | Java
1:46:28
Atif Pervaiz
Рет қаралды 57 М.
Android SQLite Database Tutorial - Build Note Taking App
1:34:28
Master Coding
Рет қаралды 15 М.
How to Connect SQL Server Database with Android Studio
15:50
Flutter Crew
Рет қаралды 31 М.
SQLite Database for Android - Full Course
1:28:22
freeCodeCamp.org
Рет қаралды 247 М.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 101 МЛН