1 00:00:04,500 --> 00:00:09,660 In this video, we're going to set up the command line so that we can use the SQL 2 00:00:09,660 --> 00:00:13,740 ite command-line interface. Now this is actually for Windows, so if you're running 3 00:00:13,740 --> 00:00:17,160 Windows, do watch this video as we go through and I show you how to set up the 4 00:00:17,160 --> 00:00:21,330 path. But if you're on a Mac or you're running Linux, there's a separate video for you 5 00:00:21,330 --> 00:00:25,100 in this section. So go and watch that one instead of this one, because that's 6 00:00:25,100 --> 00:00:29,310 going to have everything that's needed to get to the SQLite command line 7 00:00:29,310 --> 00:00:33,590 interface working on your operating system. But okay for Windows - you're in 8 00:00:33,590 --> 00:00:38,100 the right place. So we actually are going to digress slightly and set up your 9 00:00:38,100 --> 00:00:42,320 computer to access things, as I mentioned, like the SQLite command 10 00:00:42,320 --> 00:00:46,820 line interface. And we're doing that so that we can enter SQLite commands on 11 00:00:46,820 --> 00:00:47,850 your computer. 12 00:00:47,850 --> 00:00:50,960 Alright, and you may have noticed that when you run your apps from Android 13 00:00:50,960 --> 00:00:57,300 Studio, you sometimes see a brief message pop up saying Waiting for adb. And this comes 14 00:00:57,300 --> 00:01:02,210 up as Android Studio starts the adb server on your machine, and checks that 15 00:01:02,210 --> 00:01:07,140 there's a physical device or an emulator, that it can connect to. Now adb is 16 00:01:07,140 --> 00:01:12,210 extremely useful for managing Android devices, and is the way that Android 17 00:01:12,210 --> 00:01:16,890 Studio installs and runs your apps. Now because Android Studio knows where the 18 00:01:16,890 --> 00:01:21,860 SDK is installed on your machine - this is the Android SDK - it can use tools like 19 00:01:21,860 --> 00:01:26,580 the SQLite command line interface and adb, with no problems. But for us to 20 00:01:26,580 --> 00:01:31,200 use them directly, what we have to do is add the Android SDK's platform-tools 21 00:01:31,200 --> 00:01:34,140 directory to our computer's path. 22 00:01:34,140 --> 00:01:38,670 So let's see how we go about doing that. So the first step is to see if the path's 23 00:01:38,670 --> 00:01:42,780 already setup. So make sure Android Studio is started - as you can see, it's 24 00:01:42,780 --> 00:01:47,040 opened here now - and you can open the project from the previous section, 25 00:01:47,040 --> 00:01:47,880 just fine. 26 00:01:47,880 --> 00:01:50,750 We're not actually going to use the project - we just need to get Android 27 00:01:50,750 --> 00:01:51,840 Studio running. 28 00:01:51,840 --> 00:01:55,200 Alternatively, you can just start it, as I've got it here, and just be on the 29 00:01:55,200 --> 00:01:59,430 main screen without opening a project. Now once that's started, we want to actually 30 00:01:59,430 --> 00:02:03,570 click on the terminal tab, to start a terminal session. Now we can do that in a 31 00:02:03,570 --> 00:02:09,210 few ways. We can just come down here to the Windows button, and we can - if you've 32 00:02:09,210 --> 00:02:13,470 got Windows 10 - you can just type in command, and we get the command prompt come 33 00:02:13,470 --> 00:02:16,560 up like that and I can press enter, and we get our command prompt. 34 00:02:16,560 --> 00:02:18,000 Alternatively, on an older version of 35 00:02:18,000 --> 00:02:22,170 Windows, you'll just click on here and there'll be a run window, and you type in cmd in there 36 00:02:22,170 --> 00:02:27,060 and press ENTER, and you'll get a screen similar to this one. So now if we type in 37 00:02:27,060 --> 00:02:32,940 the command adb and press ENTER, and that's checking to see whether the path's 38 00:02:32,940 --> 00:02:36,900 already been set up. As you can see, in my particular case, I've got a message 39 00:02:36,900 --> 00:02:41,400 saying 'adb is not recognized as an internal or external command, operable 40 00:02:41,400 --> 00:02:46,500 program or batch file'. So that's telling us that we do need to continue on with the 41 00:02:46,500 --> 00:02:49,800 steps in the rest of this video. But if you did get another message of something 42 00:02:49,800 --> 00:02:53,130 about adb running, that would mean that it's already been configured and 43 00:02:53,130 --> 00:02:54,390 you don't need to do it again. 44 00:02:54,390 --> 00:02:59,370 Alright, so what we need to do now is check where the Android SDK is installed on 45 00:02:59,370 --> 00:03:04,230 your computer. So go back to Android Studio. Now if you've got a project open, 46 00:03:04,230 --> 00:03:08,250 you can go to the File menu and select Project Structure, and that will get you 47 00:03:08,250 --> 00:03:11,940 to the same place as I'm about to do here. And on the welcome screen I can just click 48 00:03:11,940 --> 00:03:18,060 on Configure and go to SDK Manager. And what we're looking for is this 49 00:03:18,060 --> 00:03:23,450 Android SDK Location, and you can see on the screen there, it's in my case, C: 50 00:03:23,450 --> 00:03:29,220 \Users\tim\AppData\Local\Android\Sdk 51 00:03:29,220 --> 00:03:33,720 Quite a mouthful, but that's basically, where the Android SDK 52 00:03:33,720 --> 00:03:38,540 is installed on this computer. And it may well be different for your computer, and 53 00:03:38,540 --> 00:03:40,290 most likely, it will be different. 54 00:03:40,290 --> 00:03:45,570 So we're going to select the full path. I'm just going to copy it, like so. I'm doing 55 00:03:45,570 --> 00:03:50,250 command C, and I'm going to just open Notepad, and again, you can 56 00:03:50,250 --> 00:03:53,670 either, in the Run window, you can type in notepad, or in the case of Windows 10, I 57 00:03:53,670 --> 00:03:57,200 can just type notepad or type in enough letters, and it pops up the match, 58 00:03:57,200 --> 00:04:02,190 and I'm gonna open Notepad. I'm going to paste in that path, so you can see the path that I 59 00:04:02,190 --> 00:04:07,700 got from Android Studio is now in the Notepad. And again, don't worry if yours 60 00:04:07,700 --> 00:04:10,920 is different. If you copied it from Android Studio, then it will be the 61 00:04:10,920 --> 00:04:17,480 correct path to wherever your SDK is installed. Now adb and SQLite are 62 00:04:17,480 --> 00:04:21,899 actually stored in a folder called platform-tools, within the Android sdk 63 00:04:21,899 --> 00:04:26,580 folder. So what we need to do is, on the end of this path that we've 64 00:04:26,580 --> 00:04:30,510 copied from Android Studio, we're gonna put another backslash and type platform- 65 00:04:31,320 --> 00:04:38,610 tools, like so. And you can see we've got the entire path showing on the 66 00:04:38,610 --> 00:04:42,750 screen there. Once we've done that, we need to copy this again. So I'm selecting 67 00:04:42,750 --> 00:04:46,650 and I'm doing a command c, or you can just right-click and select Copy, 68 00:04:46,650 --> 00:04:52,500 either way, and we need to then put this path into the system. Now Android Studio 69 00:04:52,500 --> 00:04:56,100 won't actually detect the path change until it restarts, so I'm going to exit 70 00:04:56,100 --> 00:04:59,280 Android Studio anyway, now, because we're done with that - we don't need that anymore. 71 00:04:59,790 --> 00:05:04,740 Then we're going to go into the Windows control panel, or settings, to make this 72 00:05:04,740 --> 00:05:10,020 change. Now, if your computer's got a Windows key, then the quick way for all 73 00:05:10,020 --> 00:05:14,550 versions is to use the Windows and Pause button - and sometimes Pause and Break 74 00:05:14,550 --> 00:05:17,490 are on the same key, normally at the top right of the keyboard. 75 00:05:17,490 --> 00:05:20,970 However, some laptops can be different. But that's the quickest way to get into 76 00:05:20,970 --> 00:05:26,910 the options - the options where we want to go. And in my case, what I'm going to do 77 00:05:26,910 --> 00:05:30,660 is, I'm going to click on the Windows button and click on settings. And you might 78 00:05:30,660 --> 00:05:33,630 need to click on that and select Control Panel, depending on your version of 79 00:05:33,630 --> 00:05:38,430 Windows. Alright, now what I'm going to do - there'll be a couple of ways for you to get to 80 00:05:38,430 --> 00:05:42,120 the area in Control Panel settings that we need to get into. On Windows 10, I 81 00:05:42,120 --> 00:05:46,350 can just type in advanced, and I can click on View advanced system settings - 82 00:05:47,670 --> 00:05:50,070 that's going to get me there. But you may actually have an option to go into 83 00:05:50,070 --> 00:05:55,080 System on an older version of Windows, to get to the same screen. And if you clicked 84 00:05:55,080 --> 00:05:59,280 on the Windows key and Pause, a Windows option will pop up and there'll be a 85 00:05:59,280 --> 00:06:03,060 little link you can click on to select Advanced system settings. Bottom line is, 86 00:06:03,060 --> 00:06:07,680 you want to get into this little screen, as we can see here now. And the other way 87 00:06:07,680 --> 00:06:11,040 you can do it, just in case you're having trouble finding it, on Windows with 88 00:06:11,040 --> 00:06:14,940 versions before Windows 10, just right- click the My Computer icon on your 89 00:06:14,940 --> 00:06:17,370 desktop and choose Properties, and you're there. 90 00:06:17,370 --> 00:06:21,510 Windows 10 doesn't have an easily accessible My Computer, so press the 91 00:06:21,510 --> 00:06:24,960 Start button and type environment, would be another way of doing it. So you'll get 92 00:06:24,960 --> 00:06:28,200 two options in that case, but the first one does nothing so click the second 93 00:06:28,200 --> 00:06:28,740 one. 94 00:06:28,740 --> 00:06:31,800 Alright, so we're going to be, now, changing something here in the System 95 00:06:31,800 --> 00:06:36,510 Properties under Advanced. So from the System Properties, you want to click on the 96 00:06:36,510 --> 00:06:41,970 Environment Variables down here. Now unless you're already really comfortable with 97 00:06:41,970 --> 00:06:44,770 doing this, leave the system variables alone. 98 00:06:44,770 --> 00:06:49,330 If you mess up the system path variable, it can actually be quite difficult to 99 00:06:49,330 --> 00:06:54,030 recover from. But under the User variables at the top here, there may or 100 00:06:54,030 --> 00:06:58,000 may not already be a path variable defined. If there is, you want to click on 101 00:06:58,000 --> 00:07:02,110 it and click Edit, but if their isn't, you wanna just click New. So, assuming if that 102 00:07:02,110 --> 00:07:05,970 said path, over here to the left, I'd click on Edit. But in my case, I 103 00:07:05,970 --> 00:07:10,930 haven't got a path variable so I'm going to click on new. And because it's new, I'm 104 00:07:10,930 --> 00:07:14,220 going to type path, but if you were editing at that point in time, you 105 00:07:14,220 --> 00:07:17,650 wouldn't touch the Variable name because that would already be set to path. You'd 106 00:07:17,650 --> 00:07:22,330 be only working in this Variable value section. Now if there was something already 107 00:07:22,330 --> 00:07:25,300 in this path - lets just say that you got there and there was already something like that 108 00:07:25,300 --> 00:07:28,500 showing - leave that in there. You don't want to delete what's already in there, 109 00:07:28,500 --> 00:07:32,380 but you want to put a semicolon on the end of it, and then paste in what you've 110 00:07:32,380 --> 00:07:36,210 copied out of Notepad - so that they're actually both there. But in my case, I'm 111 00:07:36,210 --> 00:07:40,240 going to delete that because, of course, we didn't have a path User Variable. So 112 00:07:40,240 --> 00:07:43,840 I'm just going to paste in purely that link, that we got out of Notepad, and click 113 00:07:43,840 --> 00:07:50,740 on OK. So once that's done, we can then click on OK, and we can click on OK again, and the 114 00:07:50,740 --> 00:07:55,780 change has now been made. Now, what we're going to do now is close that down. And 115 00:07:55,780 --> 00:07:59,800 we'll leave Notepad for now, but we can probably close that and not save 116 00:07:59,800 --> 00:08:00,660 it in a minute. 117 00:08:00,660 --> 00:08:04,090 So now we're here, what we're going to do is, we're going to type in a command as 118 00:08:04,090 --> 00:08:09,900 we typed before - adb - to see whether it works. And if you do get an error like that, 119 00:08:09,900 --> 00:08:15,960 what you'll need to do is click, type exit and close that down. Then we need to do the 120 00:08:15,960 --> 00:08:19,240 same process to actually open the command window again. So in my case, I'm 121 00:08:19,240 --> 00:08:26,460 going to type command, and I'm going to type adb again. And you can see now, that 122 00:08:26,460 --> 00:08:30,210 we've got a whole heap of mumbo-jumbo there, but the bottom line is that 123 00:08:30,210 --> 00:08:33,130 this time it didn't come up and say it wasn't able to be found. 124 00:08:33,130 --> 00:08:36,390 So what that's actually telling us, is that we've now configured the path 125 00:08:36,390 --> 00:08:41,770 successfully, and in the next video, we start actually looking at how to 126 00:08:41,770 --> 00:08:45,450 use this SQLite. We'll be able to access that, and that's because the SQL 127 00:08:45,450 --> 00:08:49,890 ite is in the same path as this adb. And if you really wanted to, at this point, we could 128 00:08:49,890 --> 00:08:57,070 now type sqlite3 and press ENTER, and you can see now, that we've got an option 129 00:08:57,070 --> 00:08:58,570 coming and it says SQLite version 130 00:08:58,570 --> 00:09:03,790 3.9.2. So again, this is our way of accessing databases, 131 00:09:03,790 --> 00:09:08,530 and we've confirmed we can use both ADB and SQLite, so we're good to go. So 132 00:09:08,530 --> 00:09:15,430 we can quit out of here, and the way to quit out of there, is just to type .quit. 133 00:09:15,430 --> 00:09:21,430 And that's it. So that's the end of this video. We've tested that ADB is working, 134 00:09:21,430 --> 00:09:25,510 but more importantly, we've also tested that SQLite is working. And now 135 00:09:25,510 --> 00:09:28,780 that means that we're ready to go and start working on this in the next video. 136 00:09:28,780 --> 00:09:33,130 So because this is the Windows video, you want to skip the Mac and the Linux videos 137 00:09:33,130 --> 00:09:36,760 now, that are following this one, and move on to the video after when we're gonna start 138 00:09:36,760 --> 00:09:39,550 using SQLite. So I'll see you in that next video.