1 00:00:01,480 --> 00:00:07,630 Welcome back in this video, we're going to look at what retrofit is in order to then being able to 2 00:00:07,630 --> 00:00:12,700 use it because we're going to use it in order to get data out from the internet, which we then want 3 00:00:12,700 --> 00:00:16,630 to display because the news is something that is constantly being updated, right? 4 00:00:16,630 --> 00:00:18,990 And that's not something we would have locally on our PC. 5 00:00:19,270 --> 00:00:22,450 So on our phone, we need to get it from the internet. 6 00:00:22,450 --> 00:00:24,530 So let's look at what a retrofit is. 7 00:00:24,550 --> 00:00:28,060 Therefore, we first need to understand what a restful API is. 8 00:00:28,450 --> 00:00:36,730 So API stands for application programming interface, which is a set of rules that defines how applications 9 00:00:36,730 --> 00:00:38,720 can communicate with each other. 10 00:00:39,850 --> 00:00:41,860 And then there are rest APIs. 11 00:00:41,860 --> 00:00:51,220 So representational state transfer API ice, which are restful APIs, and it is a web application programming 12 00:00:51,220 --> 00:00:57,580 interface that provides a flexible way of communicating and integrating applications with online backend 13 00:00:57,610 --> 00:00:58,600 or servers. 14 00:00:59,710 --> 00:01:05,920 So networking in Android is mostly associated with connecting your Android application to a backend 15 00:01:05,920 --> 00:01:11,230 server to ensure a user's proper data management and synchronization between all of their devices. 16 00:01:11,470 --> 00:01:18,760 Applications need to connect to an online bank, and so users can have proper back up on their personal 17 00:01:18,760 --> 00:01:22,480 data and easily switch devices without fear of loss of data. 18 00:01:23,440 --> 00:01:27,960 So let's look at the networking process for network to be successful. 19 00:01:27,970 --> 00:01:35,170 There needs to be a client and a server so a client can be any of your devices, phones or tablets, 20 00:01:35,170 --> 00:01:36,700 laptops or even browser. 21 00:01:37,150 --> 00:01:43,300 While the server can be any central computer or program that controls or provides the information that 22 00:01:43,300 --> 00:01:44,770 you need and the client. 23 00:01:44,770 --> 00:01:50,560 So your phone, for example, sends a request to the server and the server then sends a response back 24 00:01:50,860 --> 00:01:51,820 with retrofit. 25 00:01:51,820 --> 00:01:55,570 Connecting your Android application to an online server becomes a lot easier. 26 00:01:55,780 --> 00:02:02,500 You can use its abstracted interfaces to request data and receive responses from the server. 27 00:02:02,800 --> 00:02:08,979 It's a third party library because it was not created by Google, but by an external team of developers. 28 00:02:10,300 --> 00:02:18,100 So let's look at retrofits most used methods that can be used to make specific requests to a rest API. 29 00:02:18,610 --> 00:02:21,550 And the first one will be at Get. 30 00:02:21,730 --> 00:02:26,470 So the Get method tells the server that you need to read data from it. 31 00:02:27,160 --> 00:02:33,070 Then there is the post method that tells the server you need to create or add data to it. 32 00:02:33,790 --> 00:02:39,160 Then there's the method that tells the server that you need to update an already existing piece of data. 33 00:02:39,970 --> 00:02:46,780 And finally, we have the delete method that tells the server that you need to delete specific data 34 00:02:46,780 --> 00:02:47,290 from it. 35 00:02:48,190 --> 00:02:55,000 So it's actually a create, read, update and delete process, which is also known as chroot operations. 36 00:02:55,000 --> 00:03:02,020 So Create C are for it you for update and D for delete. 37 00:03:02,020 --> 00:03:08,620 So crude operations will learn more about using Retrofit with Android throughout the section. 38 00:03:08,620 --> 00:03:14,800 So we're going to actually use Retrofit and we'll get our data from the internet in order to display 39 00:03:14,800 --> 00:03:16,000 it in our application.