In this video, we're going to set up the command line so that we can use the SQL
ite command-line interface. Now this is actually for Windows, so if you're running
Windows, do watch this video as we go through and I show you how to set up the
path. But if you're on a Mac or you're running Linux, there's a separate video for you
in this section. So go and watch that one instead of this one, because that's
going to have everything that's needed to get to the SQLite command line
interface working on your operating system. But okay for Windows - you're in
the right place. So we actually are going to digress slightly and set up your
computer to access things, as I mentioned, like the SQLite command
line interface. And we're doing that so that we can enter SQLite commands on
your computer.
Alright, and you may have noticed that when you run your apps from Android
Studio, you sometimes see a brief message pop up saying Waiting for adb. And this comes
up as Android Studio starts the adb server on your machine, and checks that
there's a physical device or an emulator, that it can connect to. Now adb is
extremely useful for managing Android devices, and is the way that Android
Studio installs and runs your apps. Now because Android Studio knows where the
SDK is installed on your machine - this is the Android SDK - it can use tools like
the SQLite command line interface and adb, with no problems. But for us to
use them directly, what we have to do is add the Android SDK's platform-tools
directory to our computer's path.
So let's see how we go about doing that. So the first step is to see if the path's
already setup. So make sure Android Studio is started - as you can see, it's
opened here now - and you can open the project from the previous section,
just fine.
We're not actually going to use the project - we just need to get Android
Studio running.
Alternatively, you can just start it, as I've got it here, and just be on the
main screen without opening a project. Now once that's started, we want to actually
click on the terminal tab, to start a terminal session. Now we can do that in a
few ways. We can just come down here to the Windows button, and we can - if you've
got Windows 10 - you can just type in command, and we get the command prompt come
up like that and I can press enter, and we get our command prompt.
Alternatively, on an older version of
Windows, you'll just click on here and there'll be a run window, and you type in cmd in there
and press ENTER, and you'll get a screen similar to this one. So now if we type in
the command adb and press ENTER, and that's checking to see whether the path's
already been set up. As you can see, in my particular case, I've got a message
saying 'adb is not recognized as an internal or external command, operable
program or batch file'. So that's telling us that we do need to continue on with the
steps in the rest of this video. But if you did get another message of something
about adb running, that would mean that it's already been configured and
you don't need to do it again.
Alright, so what we need to do now is check where the Android SDK is installed on
your computer. So go back to Android Studio. Now if you've got a project open,
you can go to the File menu and select Project Structure, and that will get you
to the same place as I'm about to do here. And on the welcome screen I can just click
on Configure and go to SDK Manager. And what we're looking for is this
Android SDK Location, and you can see on the screen there, it's in my case, C:
\Users\tim\AppData\Local\Android\Sdk
Quite a mouthful, but that's basically, where the Android SDK
is installed on this computer. And it may well be different for your computer, and
most likely, it will be different.
So we're going to select the full path. I'm just going to copy it, like so. I'm doing
command C, and I'm going to just open Notepad, and again, you can
either, in the Run window, you can type in notepad, or in the case of Windows 10, I
can just type notepad or type in enough letters, and it pops up the match,
and I'm gonna open Notepad. I'm going to paste in that path, so you can see the path that I
got from Android Studio is now in the Notepad. And again, don't worry if yours
is different. If you copied it from Android Studio, then it will be the
correct path to wherever your SDK is installed. Now adb and SQLite are
actually stored in a folder called platform-tools, within the Android sdk
folder. So what we need to do is, on the end of this path that we've
copied from Android Studio, we're gonna put another backslash and type platform-
tools, like so. And you can see we've got the entire path showing on the
screen there. Once we've done that, we need to copy this again. So I'm selecting
and I'm doing a command c, or you can just right-click and select Copy,
either way, and we need to then put this path into the system. Now Android Studio
won't actually detect the path change until it restarts, so I'm going to exit
Android Studio anyway, now, because we're done with that - we don't need that anymore.
Then we're going to go into the Windows control panel, or settings, to make this
change. Now, if your computer's got a Windows key, then the quick way for all
versions is to use the Windows and Pause button - and sometimes Pause and Break
are on the same key, normally at the top right of the keyboard.
However, some laptops can be different. But that's the quickest way to get into
the options - the options where we want to go. And in my case, what I'm going to do
is, I'm going to click on the Windows button and click on settings. And you might
need to click on that and select Control Panel, depending on your version of
Windows. Alright, now what I'm going to do - there'll be a couple of ways for you to get to
the area in Control Panel settings that we need to get into. On Windows 10, I
can just type in advanced, and I can click on View advanced system settings -
that's going to get me there. But you may actually have an option to go into
System on an older version of Windows, to get to the same screen. And if you clicked
on the Windows key and Pause, a Windows option will pop up and there'll be a
little link you can click on to select Advanced system settings. Bottom line is,
you want to get into this little screen, as we can see here now. And the other way
you can do it, just in case you're having trouble finding it, on Windows with
versions before Windows 10, just right- click the My Computer icon on your
desktop and choose Properties, and you're there.
Windows 10 doesn't have an easily accessible My Computer, so press the
Start button and type environment, would be another way of doing it. So you'll get
two options in that case, but the first one does nothing so click the second
one.
Alright, so we're going to be, now, changing something here in the System
Properties under Advanced. So from the System Properties, you want to click on the
Environment Variables down here. Now unless you're already really comfortable with
doing this, leave the system variables alone.
If you mess up the system path variable, it can actually be quite difficult to
recover from. But under the User variables at the top here, there may or
may not already be a path variable defined. If there is, you want to click on
it and click Edit, but if their isn't, you wanna just click New. So, assuming if that
said path, over here to the left, I'd click on Edit. But in my case, I
haven't got a path variable so I'm going to click on new. And because it's new, I'm
going to type path, but if you were editing at that point in time, you
wouldn't touch the Variable name because that would already be set to path. You'd
be only working in this Variable value section. Now if there was something already
in this path - lets just say that you got there and there was already something like that
showing - leave that in there. You don't want to delete what's already in there,
but you want to put a semicolon on the end of it, and then paste in what you've
copied out of Notepad - so that they're actually both there. But in my case, I'm
going to delete that because, of course, we didn't have a path User Variable. So
I'm just going to paste in purely that link, that we got out of Notepad, and click
on OK. So once that's done, we can then click on OK, and we can click on OK again, and the
change has now been made. Now, what we're going to do now is close that down. And
we'll leave Notepad for now, but we can probably close that and not save
it in a minute.
So now we're here, what we're going to do is, we're going to type in a command as
we typed before - adb - to see whether it works. And if you do get an error like that,
what you'll need to do is click, type exit and close that down. Then we need to do the
same process to actually open the command window again. So in my case, I'm
going to type command, and I'm going to type adb again. And you can see now, that
we've got a whole heap of mumbo-jumbo there, but the bottom line is that
this time it didn't come up and say it wasn't able to be found.
So what that's actually telling us, is that we've now configured the path
successfully, and in the next video, we start actually looking at how to
use this SQLite. We'll be able to access that, and that's because the SQL
ite is in the same path as this adb. And if you really wanted to, at this point, we could
now type sqlite3 and press ENTER, and you can see now, that we've got an option
coming and it says SQLite version
3.9.2. So again, this is our way of accessing databases,
and we've confirmed we can use both ADB and SQLite, so we're good to go. So
we can quit out of here, and the way to quit out of there, is just to type .quit.
And that's it. So that's the end of this video. We've tested that ADB is working,
but more importantly, we've also tested that SQLite is working. And now
that means that we're ready to go and start working on this in the next video.
So because this is the Windows video, you want to skip the Mac and the Linux videos
now, that are following this one, and move on to the video after when we're gonna start
using SQLite. So I'll see you in that next video.