 Okay, so I'll be starting with a user interface. So this is one of the most important topics in Android because user interface is all about what user sees on the screen, how you interact with the screen and all that. So when you download an app or something, you first see the user interface, the GUI of it. How is the color, how is the background, how are the graphics? So I'll not be telling you very deep in the designing part of it, how to design it, but a basic components of it. This is a kind of revision of all that you have experienced. Okay, before that let me ask, how many of you are currently using a smartphone? Okay, maximum of two. And how many of you do not have any idea about any smartphone? You have never seen, I mean, never felt that any kind of smartphone, tablet, Windows, Android, anyone? Okay, nice, no one. So you all know what smartphones are, what tablets are, or any Android or smartphone device, okay? So we will be relating of your experiences, how you look at things from a user point of view and how you have to look them from the developer's point of view, okay? So these are the contents. And my session will be both theory as well as practical. I'll be giving you small demonstrations about various apps. I'll not be making applications here, but I have code with me, and I'll be going through them, okay? So you can have a glimpse of it. So these are the contents I'll be going through, introduction to user interface, layouts, UI controls, menus and tools, notifications, dialogues, sliding draw, dragon drop and fragments. So let's start with the first topic. The face is all about the screen. What do you look at? What do you touch? What do you drag drop? And where your touch leads you to, okay? So Android provides a number of pre-built structures. You are, many of you have already developed Android applications. So you know, you can drag drop a button here and there, and you don't have to code much for a button, for at least making a button, okay? So Android has a variety of pre-built structures, dialogues, notifications, menus. Then there are two ways to declare or implement user interface. Write Java code, like in Java you can, you used to do, you make, you used to make a button in Java file and then implement the code for it. Here also you can do the same thing, write Java code, make a button and write the logic also for it. Or there is one more option, you go to our XML file, declare the button, drag and drop a button, then you'll see its properties and you can change its properties your way. You can define or declare some of the properties in the XML file. So one more thing, in this session I'll be repeatedly talking about Java file, XML file, Java file, XML file, because UI is all about these two files, okay? So, and a better approach is to start with XML file, drag and drop something, then go to Java file and write the logic for it, okay? Then layouts, so what are layouts? The way in which the components are arranged, and the way in which the components are arranged. When you design a website or any application, you have an idea that a text view should be here, image should be here, button should be down somewhere. So all this is layout, okay? Again, the layouts you can define them in two ways in Java file and in XML file. So I'll skip this, then types of layouts. There are four types of layouts, linear. It is again subdivided into two parts, horizontal, vertical, then table layout, grid layout and relative layout. I'll explain these by an example. I'm switching my workspace, you have this option also? Oh yeah, UI workspace. So I have my source code, various source code applications in this workspace, I'll just run it and show you the code, okay? So this is my layouts. Layouts we define in XML file, okay? Let me first run in and show you the output. See if the AVD is not running, it will take a lot of time to start the AVD and run an application. Better you keep it running in the background so that it will not take much time for an application to run again. Okay, let me go through the XML file till then. So this panel in the between is a palette, okay? Here you get all the widgets. You can drag and drop something here, okay? And it contains text view, text fields, then list view, expandable list, everything, almost all the widgets that we use commonly are present here. You don't have to write a code for them. You just have to write the logic for them, okay? So this is the graphical layout and this is the XML part, okay? Here I've used a linear layout. So let me explain each and every property or attribute of it. So when I drag and drop this linear layout, I get this pre-built, I have not written this code. I have just dragged from here and dropped it here. Layout, I'll get here. Linear layout, drag and drop it here and this file is made by itself. Nothing I have written in it, okay? Except the text, of course. So this is my linear layout, then button, button ID. This attribute is important because when you write the logic for it, you have to refer to the XML file button, okay? There should be a link between the Java file and the XML file. That link is provided by the ID, that recognition of a separate of each and every attribute is provided by ID, okay? Each and every widget, sorry. So this button is supposed a widget and its recognition, it gets from ID. So then layout, width, height, DP is density pixel. You can decrease in piece according to your wish. There are some more units. It is one of DP is one of the unit, okay? Then height, wrap content. Wrap content means it will take the height according to its content. Also, width according to its content. If we write wrap content and width. Then all the attributes are same. Text, you can write manually. Okay, let's see the output. This is my output. I hope it's little bit visible till the end. If not, tell me, I'll go to the slides and will explain you. So I'll first start with the linear layout. This is just a button, okay? As we have seen, linear layouts are of two types, horizontal and vertical. So this is the vertical one. Here everything will be arranged in a simple line, as you can see. And horizontal in a horizontal line. Then comes grid layout. In grid layout, things are arranged in the form of rows and columns, okay? So this middle button, 1.3 is slightly longer and the button below it, 2.3, does not occupy a whole of the space. That is, it follows a property called wrap content that we have seen, okay? It occupies space as required by its text, table layout. Here again, everything is arranged in the form of rows and columns. The only difference is that this button, 1.3 is longer and 2.3 occupies whole of the space. That is, it follows a property match parent, a space as taken by its parent. It will occupy all of it, okay? So that is the difference I'll show you once again. Grid does not occupy whole of the space and table it does occupy. Then is relative layout. As you can see, there is no actually a pattern. You can drag and drop anything everywhere. Also, in a XML file, you can have as many layouts as you want. You can have a linear layout, then inside it a table layout and a relative layout. So it depends, okay? According to your UI, how complicated your UI is. You can have as many layouts as you want. Then let's go to the next topic, then UI control. These are the some of the very basic. When you go to a website, you register somewhere, something, these are the things you fill up or you see in a simple form, okay? So text view is a label kind of thing. You cannot override on it. Edit text, you can write something. There is a text given where you can write. Button, you know, you click and something happens. You go to somewhere, okay? Then radio button, checkboxes. These are basically options, various options and spinners. This is the form which I'm going to explain, okay? This is the final output which I'll be receiving. Closing this, here comes form. I'm running it beforehand so that doesn't take much time. Okay, now this is my Java file and in RES folder, layout comes my XML file, okay? And XML file, graphical layout. So that is not showing me the graphical layout because API level is not correct. So I'll reduce to a lower version. Now it's showing me something. See, sometime it happens that in graphical layout, you don't see a perfect thing, but in your device, you see how it is going to look like because finally your output is for the device. So better you check things with your device. It may vary in XML file. So this is my XML file here. I'm using a table layout, then table row. In table layout, you have to define attributes in a table row, okay? So this is table row, then end of table row. And first row, I have a text view and edit text. Again, more or less the same attributes, ID, you have seen, width, height, text. Edit text, EMS is the size of it. Then second row, third row. Again, radio button are described in radio group, okay? You first, the drag and drop radio group, then in that, actually when you drag and drop from here, as many radio buttons as you want, it will automatically come in this. You don't have to write it. Then end of first row, okay? So let's see the Java code now. Yeah, here I have declared variables, a spinner type. All these are classes, spinner, button, checkboxes, radio button. I have declared these variables. Then this is my array, my Java code. Here I have declared variables, I'm repeating. Then this is array. Array I've used for the spinner, okay? Spinner is a kind of list. When I click on the list, number of items will be displayed to me. Then edit text, yeah, here. Now, like I told, whatever I declare in XML file and I write logic in Java file, there has to link between the two things. So this line provides me the link. This final edit text, the name of edit text, r.id.edit text one. This was the id there, okay? So this line provides the link. Then button, then here comes spinner, okay? Spinner id, then array adapter. Array adapter is actually used to pull out the content from this array to the spinner. Okay, it is kind of bridge between the array and spinner. All this code you will get on GitHub, okay? If you want to try it later. Then this is event handling on the button, reset button and submit button. Yeah, nothing is there. If you click on this, usually what happens when you click on submit button, your data goes to the database. But here, since I'm not showing you any database on clicking both the buttons, a form will reset, okay? So mainly same code for reset and submit button. See the output. Yeah, I'm just changing from to portrait view. Okay, it might be not be visible at the end, but so I'm writing my name and I have. This are radio buttons, okay? Now this is the spinner. It gives me name of various countries. We'll get the complete list. Then is checkboxes. The main difference between radio buttons and checkboxes is this. In radio button, you can select only one option, right? But in checkboxes, you can select, even all the options, it doesn't matter. Click on submit button, it will reset, okay? So this is my form. Now the next thing, menus and tools. So tell me what is a menu in your smartphone? When you first open the smartphone, what do you do? Menu option. So what is a menu option? One guy just sleeping, wake up. What is a menu option? Where do you find a menu option? If not in a smartphone, then where? Next stop. So what is a menu? Gives you some options, okay? So the same way, there are various kinds of menu in this particular lecture. I'll be telling you about only two main options menu and pop-up menu, okay? So options menu is, when you click on the menu button, what do you get? That is the options menu and pop-up menu is a pop-up list. I'll let you know what is the difference. Again, we moved and toast is a, you know what a tooltip is? When you select something and not click on it, you get a tooltip. So toast is not exactly a tooltip, but a kind of tooltip or a feedback about operation. Again, the code, like I said, I'll be jumping from Java to XML file. That's what I'm doing. I'm running this. Here comes my Java file and my XML file. Okay, so this is my main XML file. Here I have only a text to you, nothing else, okay? And here, this is what I've written. Click on the menu to show menu items. Now this is my another menu file. Okay, what happened again? Again, I'm reducing the API level. You may find these kind of error. These are, you know, I was working on some other PC and I transferred this, so some default changes may happen. Just that. It's showing me no XML content. That's fine, yeah. So it is little different from the main XML. Here you don't have an option to drag and drop anything. Okay, yeah. Now every option of yours, when you click on the menu button, every option is described in the form of an item. So this is item bookmark, okay? It has certain attributes, ID, icon, like that. So here I have six options in the options menu. So all these are described in item attribute. See, it can be a little boring, but you know, from the developer's point of view, these are the basic things from where you have to start your design. Click on the menu button to show menu items. Menu items are displayed. I'll change the to landscape. Yeah. So here, these are the items that we declared in the menu.xml file. So if I click on any one of these, search is selected. So this is the toast, that tooltip I was talking about, okay? Again, I click on menu button, some other item. Delete is selected. It goes, it comes and goes, it comes on buttons on some click and goes by itself, okay? That time you have to mention in your code. So now let's see the code. So menuInflator is used to initiate the xml file, that is r.layout.menu. For an item, you have to write r.id.id name, and for file, that is an xml file, in this case, you have to write r.layout.thefilename. Switch case is used. Switch case, you must be aware, it's same as C++ or Java switch case. You write, when you click on different item, a toast appears with a different text, that's it. So this is the coding for toast, okay, this one. So here toast.lengthShort, so this is the duration. LengthShort, if you give length, medium or length long, it will appear for a long time, okay? Comparatively long time. This is about the Java file. Here right now I'm showing very basic, simple code, each a separate file for every widget, but when you'll be creating your applications, it will be much more complicated than this is, okay? So just to start with, so that you don't get afraid of Android, I'm starting with this. Okay, now next is pop-up menu, okay? Here's my Java file, and also if you have more than one Java file, don't forget to add it in android.manifest file, manifest.xml, sorry. Now this is my graphical layout. This is the main file. Here I'm displaying a button. On click of this button a menu will appear, and this is my menu layout.xml file. So here in every layout I'm displaying a text view. Basically these are toasts, okay? Now in Java file, again inflator. Here I'm using layout inflator to pull that content from the XML file, okay? Now event handling is done on this button, okay? Show pop-up window. On clicking it will enable it, and you click somewhere outside, it will disable it. I'm not going very deep into the code because you won't be able to understand it in this point of time for sure because, okay, forget it. So I'm telling you just the brief idea of it, what is going on. Show pop-up, three options it will show you, and when you click on any one of them, click once here, you will see three methods. Click one, click two, click three. Because I had three items in my options menu, so on clicking one you'll get one toast with some other text. On second click you'll get another toast with some other text, that's it. So this is my output. Control F11 is the shortcut to change this. Form, from layout to, from portrait to landscape or vice versa. Then search, I click search, tab search. So this is my toast. Toast is a simple one line thing, you know. If you want to show that something is happening on the click, just write down toast. Notifications now. Since you all are users of smartphone, you know very well what notifications are. You just now had a brief discussion about it. So what are notifications? Other than a WhatsApp example. When you, when you're using a smartphone, at what times you get a notification? Message. Sorry? Updates. Updates, okay, what else? Sorry? Reminders. Reminders, okay. Battery. Battery low. When you're using it, do you get it? When you click on camera, you don't get a permission thing. Miss call for example. So your notification is a message. When you slide down, you know, on your home screen, you get a black pane, panel kind of thing. So that is a notification area. So and when you slide down, that is called a notification drawer, okay? So these are two technical terms. So let's go to the code again. My Java file and my XML file. My XML file contains simply a button, nothing else. When I click on this button, I'll get a notification. Okay, so notification manager is used to create a notification here. Event handling is done. Now you can see your deprecation. Deprecation as, you know, you saw in the first lecture that API levels come every year, every month. So some of the methods get deprecated and some new thing, better thing comes into play. So if you have written a code into our earlier version, so this will give you an error. So if you can want, if you can change it, otherwise it will give you an option that it will display here deprecated, that's it. Your code will run, but it will give you an option deprecate, give you a line deprecated, that's it. Okay, then notification manager is used to create a notification. Then here is my notification text. This is my notification file, stat notification. And you have been notified. After clicking, what comes in the notification is this. Continue with what you are doing. This is, I'll let you know when you see the output. Then intent is used to switch between the notification and to the previous activity. Because when you're doing something and notification comes, you suddenly jump to that notification. So intent is used to, you know, pass to that notification and then to come back. Even between activities to jump from one activity to another, intents are used. Notification, now here up, a notification has arrived, okay? Slide it down. So this is my notification drawer that I slide it down, okay? Now you have been notified and continue with what I'm doing. So when I click on this, I'll come back to my previous activity, okay? So even you can do a thing, when you click on this notification, you can give a URL or something. So it will jump to your browser. So a lot of things you can do with the notification. And then next. So this is the notification drawer, slide up down. And this is the notification area, okay? Technical terms. Now dialogues. Dialogues are something, you know, we use MS Office usually. And when we type something and we don't save it, we try to close it. We get a dialogue. Do you want to save or you don't want to save? So that is simple dialogue. And dialogues, it just asks the user to input something, to make a decision, yes or no, cancel something. That is a small window. It asks user to respond to take a decision. So XML file contains a simple button. I'll click on that and I'll get a dialogue box. Then this is my Java file. Then I'll go to the event handling here. See, when you implement onclick for a button, you can do that in XML file also. There is a property. You can go there and write onclick. And even here you can set that. There is a basic difference between the two and that you will have to explore. Okay? So onclick listener is a method of view class. See, every widget comes under view. Now onclick. Here I'm setting a title, a background. Then here set positive button, yes. On yes, what will happen? That I'll go to the main, that my main activity will be finished. And on no, what will happen? Nothing will happen. The dialogue will get canceled. That's it. Okay? Builder is used to create a dialogue box and dot show method to show it. Dot box, click yes to exit. Suppose I click no, nothing will happen. That is my dialogue box will cancel. Yes, I'll go to my previous activity. That was notifications. Okay? Now the next thing is sliding draw. So this, we have already seen something in notifications part when you slide down. So I'll let you know sliding draw is used to hide some content. Okay? This basically when you design something it is from the designer's point of view. You do something sliding here and something else comes. So it's good to look at. And it is better than, you know, clicking a button. Sliding is more cool to design. Okay? So it comes up with a handle. You touch a button or something and a handle appears. It is used as an overlay. Like I said, like as a cover. You cover something with sliding draw. So there is one more, I guess. Yeah. Fragments, then my session will be over. Java file. Okay, my XML file has an image view. It's giving me some error. Yeah, see it's giving me an error. So there is nothing wrong with the code. Only thing I have to do is clean the project because it has, it has got some inbuilt error. That's it. Sometimes it happens with ID. Usually it is confused or it gets grabbed with something inside it and it gives an error. Okay, here, a button I'm declaring then sliding draw. Okay, a variable of sliding draw class. Then again, I'm referring to the XML file instantiating these buttons. Okay, let's see the output first to understand better. I'm clicking on the small button. I get this. Something has appeared. So this is just to act as a overlay. That is just to hide something. And this activity will be as it is. Okay, nothing will happen to that. When you click it again, again that will happen. I mean, click this button again, the previous activity will appear. Okay, and again, toast. You know, toast is the simplest to tell you that something is happening. A simple code, yeah, sliding draw. So here, sliding, on draw open listener method is I've used to open the sliding draw. Then here, set background. Set background, you can use here also and in the XML file also, both the ways. Okay, then on draw closed, what will happen? And on draw open, what will happen? That you have to mention in these two methods. Okay, that's it. Basically, you have to go more into the logic of things, okay, because declaring things and moving here and there is very easy in Android. Then comes the next thing, drag and drop. See, smartphones are all about your touch. That system should be able to recognize your touch, okay? So this feature is very important. Instead of using buttons or clicks everywhere, it's better to use drag and drop from user point of view. You know, it is more attractive for a user. I'll give you a basic application of drag and drop. Again, I'm repeating all the slides and everything we'll get on GitHub. If you want, we'll provide you with the link, okay? So this is my output. Here, these are my containers, okay? These background things, dark blue or rectangle boxes. And this is my image. So what I'm doing, I'm just dragging here, dropping it here. I have mentioned some restrictions that it should, if I have drag and drop here, then only it should be visible. If I drag it outside, it should not be visible to me anymore, okay? So it is kind of delete thing that is happening. So let's see the code. In XML file, I'm just displaying a linear layout and that an image view. Those are the rectangular images, okay? Then here comes my image one on touch, what will happen? Touch listener is introduced here, okay? Set visibility. If it is inside the view, then it is, I mean inside the white thing, it is invisible, okay? This is on drag listener. So basically it has four components. If I drag and drop on those four components, it will be visible to me. And if it is somewhere outside those four components, it will not be visible to me. This is what the logic is. You have to restrict to a particular area, okay? These are container, that's it, okay? And everything like I said, layouts are a part of view. They are, yeah, they inherit view with them. Details of the code you can contact us anytime. Last thing, fragments. You have seen what are activities. So fragments are sub-activities. Switching to an activity could be time consuming or you may not want to be a separate activity, but you want that it should be somewhere, a part of one activity, but the code should be different or the thread should be different. So it is a kind of sub-activities. Activity can have many fragments. So when a fragment is closed, when activity is closed, all its fragments or sub-activities are closed. It is same as the life cycle of an activity, okay? But when a fragment is closed, that activity may not be closed. So a life cycle of an activity affects directly the life cycle of fragment. Let's see the output first. Basically, activity is one screen, right? So what will be sub-activities? It is a part, this part is one fragment, this part is another fragment. It is one activity, but inside that different sub-activities are playing, okay? Like your Facebook, you are chatting somewhere and here a notification comes or you know, something else is happening on the right side or on the left side. So that are different fragments of an activity, different things happening on a single screen. So this is my list view, let me change. So this is my list view is one activity. When I click here, it is displaying me five images. So that is another fragment, sorry, sub-activity. List view is one sub-activity, right side panel is another sub-activity, okay? I click on one, it will display me one image. So it may not be related, in this case they are related, but it may happen that are two independent fragments. They are not affecting each other, but something is going with both of them, independently or dependently, okay? So for fragments you have two separate files, separate classes, okay? So let's see the, yeah, XML file. Yeah, nothing, there is a list view, there is another fragment, okay? Then here comes list view that we just saw, numbers. Then array adapter, this is array. Now array is again used to pull the content from, sorry, array adapter is used to pull the content from array to the list view. Class is used to add, to make a fragment, then fragment transaction, in this case, both were interlinked, something added on first fragment, something was happening on other fragments, like I clicked four images. So this is kind of interaction, it is dependent on which button I'm clicking, those number of images I'm getting on the right side, okay? Yeah, so I've created a list view, I've taken data from array. Now this position, when I click here, I'll send this data to my next activity, next sub activity, sorry, okay? So here, and androids I have declared just to hold the count, that if I display fourth number button or the text with four, four android images should be displayed to me. And then a simple basic for loop for number of images, right? So this is fragment and fragments are very important. If it is a complicate GUI in android, a fragment is a must thing, you should be comfortable with fragments, okay? Yeah, so this is all about user interface. Also you can, you know, to make a very good attractive exotic design, there is one more thing, styles.xml, I'm not going into detail of it. You can create a folder or a raw here. Basically, if you have to put any images or video files, you have to create a folder in ares folder named raw, okay, r-a-w, sorry. And in that, you can put images or anything else. And also you can create a XML file styles.xml to create any good background for the button or any image. In this whole thing, whatever buttons I showed you were very basic, normal buttons. So if you don't want to use a image view and you want to use only a button and create something good out of a button, you can use styles.xml, you can make styles.xml. And it is very easy, you can explore it. It is just like an XML file, some attributes here and there, that's it. Okay, so this is all about user interface. Like I told you, this is very basic. Now you have to explore it, okay? As per your design, okay? Now next session will be about data storage and before that, take five minutes break. Hello, everyone. And I'm going to discuss with you about the data storage and the databases. The main purpose of the data storage is to store the data. It may be the structured data or the unstructured data. Structured data is the XML file and the databases. But unstructured data are the audio files, video files, which the machine cannot read easily. In Android, we have the several options for saving our data, like the shared preferences, creation and the storage of arbitrary file types, as well as relational databases. This creation and the storage of arbitrary file types can be further classified into the internal storage or the external storage based on the type of device. So among these kind of databases, this database we can choose for our data. So for this question, we have the solution that it totally depends upon our specific requirement. From our security purpose, we need to keep that in mind that whether the data is private or the public to the user. And from the logical point of view, we need to remember that how much space for our data or application we had required. Need to remember before creating the database or the storing the data. Now first is the shared preferences. In the shared preferences, we pass the package of information from one activity to the another activity in form of key value pairs. But the shared preferences cannot be used for passing the information from one application to the another application. It is only applicable for the one activity to the another activity. Now in key value pairs, key are the type dash strings, but the value should be the boolean long eight float or string. Now shared preferences are managed through the Java code or the special preference activity. A special preference activity are nothing but a XML file we have read so far in the Android. Now shared preferences stored on encrypted format on a disk. Now next thing, how we are going to create the preferences in Java. So for creating the preferences in Java, we need to import the shared preference class into our Android project, which consists of the set of the preferences. Now preferences instantiate with the mode of private. There are some other mode are available like the mode word writable. We can use this mode to set the mode for the application data. There are the two methods by using which we can create our activity. Preferences in the Java and activity. Now preferences for current activity and the name set of preferences. In preference for the current activity, we create the object of the shared preferences and store the get preference method into it by passing the parameter as context or mode private, which is used to set the mode. Another way is the name set of preferences in which we use the existing preference and create the preferences for our data. Like preference name and the context mode private is the parameter for the get shared preferences function. Now for using the preference activity, we need to remember the certain points like preferences, activity, define and write values to the disk automatically. And values can be string, Boolean or list of string as I told earlier. Now preference activity defines in a layout XML file. We can navigate to preference activity with an intent object. Now we are going to see the shared preference example. For the shared preference example, I had just dragged the two edit text box which is on which we are going to create our data and then two text view for displaying our data. Then two button on which certain activity performed to display the data. Now we are going to see the Java code for this. For creating the preference, we need to import the package shared, android.content.shared preferences. Then we can access these widgets using the find view by ID method. Now by after assessing these widgets using the find view by ID, we can perform the set on click listener event for the button. Then on click of the button, we can call the activity in which we call the two function which is the safe preferences and load preferences. In safe preferences, we pass the key value where MEM1 is the key and edit text one dot get text, dot two string is the value of the edit text box. From that edit text box, I am going to take the data and store it into the key which is MEM1. Then load the preferences and display our data. This is the code for safe preferences active and safe preference method. You can see that I had created the shared preference object and using the shared preference dot editor, I just use this data and store into the key. And just commit that to save the data. Then load preferences method is used to again load the data, load the data and display into the text view. By this way, we can create the preferences and display, adjust on the project and show you the functionality of this. This is the edit text box and on which I write something and just save. Then you can see the save MEM1, below the save MEM1, you can see your the data. It is like the data is stored into the temporary cache. Then you can, where you can display onto the screen only. At the time, you can, if you want to see your data at the time and display for a long time onto the screen only, then you can use this shared preferences. Shared preferences is to just to display the activity from one activity to the another activity. You can just use the data into another activity by using the shared preferences. Now, file storage. Before moving towards the file storage, we need to remember that before creating any file, we need to give it a proper name and the extension for creating our file. File can be created and read on a persistent media. Then file storage has no special file type, like store images, XML or data file or anything else. The file can be designated for internal or the external storage. From here, we can see internal storage. Internal storage is the internal memory of any device. Like you are using the smartphone or any phone, you have the some internal memory. That internal memory is limited and that internal memory is used for only the private data. Like Android, you can see this point. Android can save the files directly to the device internal storage. These files are private to the application. Means, when you install the particular application, some files are directly stored into the internal storage. Means, like the database file, if you install that file, database files are installed into the internal storage. When you uninstall that particular application, then these files are automatically removed from the internal storage. Now, we can create a file using the open file output function with a parameter as file name and the operating mode. And we can display the existing file using the file input, open file input method by just passing the file name into it. The other thing is, we need to remember is the file name with the extension should be proper. Now, we are going to see the internal storage example. In an internal storage example, I just created the two edit text box. In the first edit text box, I just, I will enter the name of the file, which I want to display. And the another edit text box in which I will store the content of the data. And that content data, I will store into that particular file, which I had created above. And this button will do this activity on click event. So, let's see the code of that Java code for this. In this, I just, I had not used any extra package. I had only used the Java packages, like the java.io. file not found exception, sometimes when exception, file not found exception occur, then it will take care of it. Then file output is streamed to display the output file. Then IO exception. Best of all are the common Android widgets, Android packages. Then here, in the same way as earlier, I just access these widgets using the find view by id function. Then on the click of the button, I just do these activities, like access the file content, edit text box contents, and store into the string. Like file name store into the file name string, then content is stored into the content string. Then I created the file output stream object. And using this object into this object, I just created the file using the open file output method. In this, I passed that file name, which I had taken from the edit text box one. Then that file name is created, and I had also passed them at mode of that file. Now, then after creating that file, I just call the write function and write that content, which is saved in the another edit text box and display into that and close that file. After that file, file close, and another thing that toast is appears as you had learned in the previous lecture to notify that that file is saved. You can see that file into the ddms. In ddms, you will find the name of the package, and into that package, you can see your file. Okay, so in this, in this, you can find your package name matching to your under project, and you can just pull that file from there ddms only. I'll just run the example and show you the functionality of the code. Now this interface will appear, and into this, I just give the some name on to the file like file one, and the content is this. Then you can see this toast appears, file one is saved, and you can drag this file from the ddms only. Now next is the external storage. As we know external storage is the any external device which we attach to our device and any Android phone, any smartphone or any devices. Now every Android compatible devices supports us shared external storage that we can use to save the files. This can be removable storage media like the SD card or the any internal storage sometimes act as an external device. Now files saved to the external storage are word readable and can be modified by the user when they enable the USB mass storage to transfer the files on a computer. Means any external device is the publicly as well. Means any user can just access the content of the file by just enabling it to the particular system. And then we attach that external device. Now external storage example. For this external storage, I just create a, I just drag and drop the image view into our layout and I want to display the images into this layer, into this image view. So for this purpose, I just written a piece of code like in this I just access the image view by using the find view by ID, then create a bitmap file into which bitmap file. I just call the bitmap factory dot decode file function into which I pass the perimeter which is the path of that image which is the MNT slash SD card slash images dot JPEG. This MNT is the default external external storage path into the ACAGE tablet. Then I just say that bitmap file into the JPEG to view the image using the set image bitmap function. Escalate relational database. As we much aware of the Escalate relational database that is for the structure data. We can use any structure data is using the Escalate relational database. Escalate relational database provides us the functionality to manage the any structure data. In Android provides the built-in support for Escalate. All the classes and interface are present in android.database.escalate package. Now database files are stored local to the app. Means these files are stored into the internal storage as I told earlier. Means when you uninstall the particular app then its database files are automatically uninstalled and removed from the internal storage. Now to share the structure data with other apps consider creating a custom content provider. As you have seen in the third lecture custom content provider are used to share the structure data. Now Escalate database example. Now for the Escalate database I just created the three XML files. This is the main dot XML on which I just create the two button save data and the check data. In save data I just store the data into the database and in check data I will retrieve the data from the database. Now in save dot XML I just created the form and fill the detail and click the save button. Then the data will store into the database. If I click the back button then it will lead me to the main dot XML. In main dot XML if I click the check data then it show the this layout in which I just display all the data into the database. Like you can see the name, telephone number, Skype ID and the address using the list view. Now for using the Escalate database we need to create the functionality for the database. For this purpose I just created the data manipulator dot data manipulator class. Into this we need to import some important packages like the Escalate dot Escalate database, Escalate open helper, Escalate statement. Escalate database is responsible for managing all the database activity like creating the database, deleting the database and executing the query. And Escalate open helper is responsible for managing the version like the version management and the creating the database. Then Escalate statement is used for representing the statement which is independent from the database query. Now I just created the data manipulator class into this as I defined the some global variable to define our database. Then I created the object of the Escalate database, Escalate database dv. Then I had created the string insert which is used to store the values I had inserted into the data into the form for storing the database into the database. It is the normal SQL query for inserting the values into the database. Now data manipulator method is called into this method. I use the open helper using the open helper. I can create the database and using this database I had created the get writeable. I call the get writeable database function. Using this function I can create the writeable database into which I can write the data. Then I just compile the statement and pass the query into it for inserting the data into the database. Now I create the function insert. Using this insert function I can bind the value to the particular column into the table. Now this is the delete function for deleting the database from that. Using the list we can assess all the rows of the table and display into the list into the layout. Now these are the various methods we can create into the for using the database using the SQLite database package. Now from our application purpose we first see the save data.java file. Into this I just create the two button add button and home button. Home button lead to the home page and add button will insert the data into the database. On the click of the add button one activity fires which create the data which store the data into the database. You can see we can assess each edit text box using the find view by add method and store the content of the edit text box into the string. Then data manipulator function is called which insert the data into the database by using the this.dh.insert function. Into this I pass the parameter as a string which contain the value from the edit text box. Then our dialog appears which appear when we save the data into the database that information saved successfully. Now another is the check data.save. In this I created the list array list into which I store the data from the database and using the data manipulator I assess all the row from the database all the data from the database by using the dm.selectAll function which is similar to the SQL query like select start from the table. Then I created the for loop up to the number of the times row is present in the database then display the data using this for loop. Now I will run the project because it is already running. Now click the save data and form is appeared and click the save button then it dialogs appears that saved information saved successfully. Then click the yes then it will store into the database. Now click the back button and check the data. You can see the data stored into the database. So that's all. Thank you everyone. Good evening everyone. And this is the last session on Android. Now we will be looking at Android media. So I will just go into basics of that. So what is Android media? Anyone like what exactly is media? Music, audio, images. So how do you display an image and then play an audio file and then play also video file? So for that this is what we will going through. Like one is image view. It's a widget to display images. Like there are many apps you see like you have images in that. There are many apps all around. So you see images in that. So for that image view is responsible. So it's a widget on that you can have images. And then comes audio. There is a class called a media player class. So with that you will be able to play audio like music players. You have music players and you listen to audio. So how does that audio file be played? So for that media player class is responsible. So with that you can listen to any song like any favorite song of yours. And then comes your video view. It's again a widget. Which is used to display, which is used to play audio file. Like YouTube also plays that videos and all everything. So first we will look at image view. So it is used to display images and icons and everything. And you can load images from anywhere. Like it can be internal SD card, external SD card even from a web link also. Anywhere you can load the image. So I will just show you. This is the example like WhatsApp. Like this is the example. Like you have profile pic. How that profile pic is being displayed. So that's a image view widget. On that video is, on that image is being displayed. So that image is being captured from what we say. We have web links from somewhere from server server. And then we have a chat list. There also you can find various images. All those are image view widgets. On that image view widgets you will find that each and every image. So how do you go about image view? So in our palette we have that image view widget. We just drag and draw into our graphical view. So along with graphical view, XML code is automatically generated. You can have a look at XML code. So that's the ID. That's very important to refer. Like you need to refer for, if you want to have on click listener on that on your image, you can use that ID, particular ID. And then the most important part is that SR source, Android colon source, SRC. Inside that drawable there is an image called as IC launcher. So if you have another image like named KitKat and you have it in your drawable folder. So after that if you write at the red drawable slash KitKat you will get your, when you run that code you will get output like this. So it's a KitKat image which is being displayed right now. So the source part is very important. Inside drawable you just need to put your images. And that's a Java code which is used to refer. Like a session before taken by Raya she told you how to refer an ID. So this is how you refer. And with this you can work on on click listener each and everything like, if you want to on click listener on that you can click an image and get any event you want with that ID. You have just created an object of that. So this was about image view. Now Android Audio, so like you listen to music and all I said already like you have media player class. So it's very simple. Like you create an object of media player then give a data source. Again the data source can be anywhere. Internal SG card, the external SG card or the web server or anywhere. So you just prepare and let's start. In this, in this way the audio file is being played as simple as that. And then comes video view. Again it's a widget which is used to play video files or video files. And it's the same way. You drag that video view widget and drop it onto your graphical view. And then you can adjust the size of your video like size of like width and height or everything. So again the external code is being generated. You can see that ID, that's again an important thing ID. So that video view one is the ID of that video view. So this is a Java code that is used to play the video file. So you can see that I have referred that r.id.videoview1, that was the ID of that video view. And then the path in string. So in the end you will find r.raw.filename. So whatever is the filename of your, whatever is the filename like abc.abc.mp4 anything you can, any file you have, you just need to name that abc. You don't need to give the extension of that like .mp4 or any other thing. So then you just pass that path, that string, particular string and then set your video URL and then just start. In this way, you can just play a video. It's as simple as that. Like there's nothing difficult in playing media files and all. It's very simple. You can display image very simply, then play audio and then again play a video. So this is how it will look like. When you play the audio, keep an audio file like this. This is a bunny file. So when you play this video file, it will look like this and you can have that controller. It can be fixed or it can be also like high. You can also hide that particular controller. So this was all about Android media. It took only five minutes. So the Android session is over and any questions regarding the entire session? Thank you.