Android Development for Beginners: Your first app in 2 hours | Vadims Savjolovs | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Android Development for Beginners: Your first app in 2 hours

teacher avatar Vadims Savjolovs, Software Developer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

36 Lessons (2h 3m)
    • 1. Introduction

    • 2. Course project overview

    • 3. Create a project

    • 4. Creating emualtor and running the app

    • 5. Project structure

    • 6. Gradle build tool

    • 7. Layouts - FrameLayout

    • 8. Layouts - LinearLayout

    • 9. Layouts - RelativeLayout

    • 10. Input controls and their attributes

    • 11. Supporting multiple screens

    • 12. Declaring layout for the Main Activity

    • 13. Activity lifecycle

    • 14. Handling user interactions

    • 15. Starting new Activity

    • 16. Declaring a layout for the AddNoteActivity

    • 17. Creating a menu

    • 18. Defining a data model

    • 19. Creating a datasource with the in-memory storage

    • 20. Splitting packages

    • 21. Saving a note to the in-memory data storage

    • 22. Initializing RecyclerView layout, separators

    • 23. Creating RecyclerView item layout

    • 24. Creating an Adapter for the Recycler view 1/2 (ViewHolder)

    • 25. Creating an Adapter for the Recycler view 2/2

    • 26. Displaying data from the DB in the RecyclerView

    • 27. Returning a result from the Activity

    • 28. Define a schema and a contract

    • 29. Create a database using a SQL helper

    • 30. Swap in-memory implementation with the DB

    • 31. Creating a NoteDetailsActivity and declaring layout

    • 32. Add click listener to the RecyclerView item

    • 33. Passing an object into the NoteDetailsActivity

    • 34. Creating menu

    • 35. Confirmation dialog and delete Note functionality

    • 36. Release to the Play Store: build a signed apk

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Welcome to the "Android Development for Beginners" course.

This is a project oriented course which will help you to learn Android app development in a straightforward and consistent way by guiding you through the real life app development process. Main objective of this course is to build a Notes app for Android using latest development tools, following material design guidelines and Android development best practices.

First we will cover key concepts and components of the Android app such as activities and their lifecycle, intents, layouts, views, resources and data storage (sqlite). After each bit of theory we will use gained knowledge to develop Notes app.

Each lecture is followed by link to the more detailed guides and documentation regarding the topic. Source code of the project app is available at each step.

This course is for everyone who wants to start building Android Apps and has at least basic knowledge of Java and Object Oriented Programming.

Meet Your Teacher

Teacher Profile Image

Vadims Savjolovs

Software Developer


Oracle Certified Professional with more than 6 years of work experience in IT field. Experience in Web and Android application development using latest Java technologies, frameworks and agile development methodology.

Working in London in a fintech startup. Responsible for banking platform Android app end-to-end development. Owning a product and responsible for a full product development lifecycle: development, testing, delivery and maintenance.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Introduction: welcome, and I hope you are ready to build your first android. My name is Bottoms and I'm a senior android developer in a fintech startup. I have designed the scores to help you to learn android app development in a straightforward and consistent way by guiding queue for the real life AB development process. This is a project oriented course, and my an objective is to build a nap where you can keep and manage your nose. We will use latest development tools and we will follow android app development Best practices to keep our code clean and maintainable that we're going to develop uring. The scores will give you ability to Adam. You note display or notes in a list you open national to review of details and delete your notes from the database. Development off the notes APP will help you to learn about key concepts and components widely used in android app, such as activities in their life cycle, intense layouts, views resource is and ask your light database. After each bit of theory, we will use gained knowledge, stored the functionality to our notes app. So by the end of the course, you will have knows app ready for publishing and enough knowledge to create your own android app. This course is designed for everyone who has basic knowledge off Java and object oriented programming and wants to start building can draw it, APS. 2. Course project overview: This is a project Orient, of course, which means that the long said with theory and examples, we're going to build a real life and worth. By the end of the course, you'll have ready to publish Russian off the notes up, which you can see launched in Miami later in the development process, you will learn about essential android components and development tools and practice, which is a good way to start learning about Kendra Tap development on the main screen. You can see a list of notes for two from the database and the full think action Battle Action Button launches second screen, where you can enter title and text of new note and save it to the database by clicking done button in the toolbar by clicking Khanna. Note. Item in the list. No detail screen is launched where you can review your no details and deleted from the database. And when you click the little button conformation, dialogue is displayed. So you need to confirm the action to build that we're going to use android components and your widgets, which you definitely were faced in the future while building your own APS, for example, or secular views at the text, overflow menu buttons activities and ask your light database. We're going to maintain high coding standards. Several hollow Kolding best practices which are widely used in professional software development industry. It's very important to build acts in the clean and maintainable way, which will blow you to support, localize and extend functionality off Europe and future. 3. Create a project: Now we have all needed development toe set up, and we're ready to go. After a quick start, A new project button. You will see a wizard with a few steps, which will help you to create on that first unit to enter your application name, you can enter any name you want. It's not necessary to have a unique app name. I'll call the APP. We're building notes, but you can choose any name you prefer on the second line. Your ask toe Enter accompany the main. It's used to generate a package. Name off your job Package Naming convention It's good practice to have your package name like this reverse company, the main plus your application name. Keep in mind that package name is unique. Identifier off your app so peckish name must be unique on your phone and on Google play store. Next step is to select a minimum as the J. It's very important to choose the right version off minimum. My pie level. You're going to support Google Play will not show that to the phones, which are running android version lover than your minimum. As the K version. You want to target as many users as you can, but you need to remember about the costs associate with supporting bold android versions. You might need to create different clothes depending on the version, because some might guys heard that a K kit. Also, each release introduces a new type guys and you hardware support. So you need to make APP available only for devices which are supporting your minimal feature set. At the moment, I would recommend to leave. I pay level 16 as this. A good trade off between iPad features you you you can use and market share on the next step under a studio is offering to choose up template. There are different types of presets, but we want to build an app from scratch. But, uh, so we chose empty activity, which basically will create a configured enteric project with one empty screen which you can run on your phone straightaway when we pressed. Next on Endor studio is offering to enter a name off the screen or in android terminology is gold and activity. I prefer to live with this name main activity to remember that this is the first activity will be launched when the user opens your app. We press finish on the weight while our project is being created 4. Creating emualtor and running the app: We have a project generated by injury studio by default with her Once Korean, which would have chosen in the Wizard and before starting to look into the project files and the source code. Let's try to run are empty app in the emulator to run the app. Place quick on the run button in the toolbar. In the dialogue you'll sell list off the connected devices and emulators. I don't have an emulator, so let's create one to create an emulator. Bliss. Quick, great noodle, we're told Device button and you will see a list off presets. There is the least of popular full models and their specifications screen size, resolution and density. I'll choose the latest phone, which is pixel Excel and click Next on the next Corinne. You need to choose a system in which, which will be running. Condemn you later. I recommend to download the latest available system image with the Google like guys Google . It guys will give you ability to use, for example, Google maps and other Google services on your emulator. When we quick next winter our phone name, and if we don't need any specific set inks, we can click finish wait a bit while devices created and run a nap on this emulator. Okay, now we see our app launched in the emulator. There's only one screen which in android terms is called activity activity has a layout which declared in the resource XML pile, the only visible you I element off the layout is a text to you with a hello world text in the middle. So we have, er thing up and running, and we're ready to start coding our notes act. 5. Project structure: before we start typing your screens and writing the cold was get comfortable with our development environment. People knew 200 development might be a little bit confused with all this tubs and buttons you see on the screen. By the way, if you don't see this stops by default, bliss quick on the icon in the left bottom corner to show them most frequently. You stab this project up where you can see your project files to navigate between them. So let's check what under a studio generated for us when we created a new project. There are a few different ways of displaying your project files In Android view. You can see all the needed files, and they're grouped in the comfortable way manifests source called Resource Is and build files. All the files which are generated in the abil process are hidden in this view. So we see Onley source files were working with another view is project for you, where you can see all the files off your project director represented in the way they're actually stored in your hard drive. Let's which book back to the android for you and go through the project files first, we have enjoyed manifest ICS a mile. The manifest file provides essential information about APP to the android system, which the system must help before it can run any off. The apse cold and Android Manifest XML file must be located in the Application root directory. Android Manifest describes the components of the application, which includes the activities, services, broadcast receivers and content providers that composed the application. In our case, you can see main activity and its declared is a launcher activity, which means that my an activity will be the first activity to be opened when you launch the at and where it manifests. Also declares the permissions that the application must have in order to access protected parts of that guy and interact to other applications. For example, if you want to consume data from the Web service, you need to add an Internet permission, which should be a child of the manifest tag. In our case, note Step isn't accessing can be protected parts of I guy, so we don't need any additional permissions. Now we can move on to the next part, and it's source cooled off our well. So are are located in a package named Comb, my company that notes, which is package name I have specified in the APC. Rage and Wizard known the package. We only have my activity. This is the screen created by default, which we have chosen in the Who is art when we created our project. So we definitely will get back to the main activity and we'll speak more about activities about their life cycle. But now let's move next to the the next folder, which is Resource folder in a resource folder we have Ah, all our resource is used in the act which are drama bols. Where can be stored images which you're using for the backgrounds for the bottoms. Also, there are layout which are layouts of your screens off your activities off your fragments off or off your dialogues. Next you can see make. My folder is also a folder where ah dropped balls are located, but now it's specific for the launcher durable and you have ah values package where ah, you can see colors, strings, styles located. So there you declare colors instead of hard coding them, and you declare strings in strings XML instead of hard coding them into the into your activities and your layouts. It's done for the purpose off localization your app because you want to translate Europe in more languages and reach the most off the users in the world. Ah, we can. We will get back toe all this concept off storing strings, dimensions and colors in the XML in the process off that development. 6. Gradle build tool: Let's think a bit about following what is actually happening when you bleak around button. I think your first thought is that behind wrong button there is a compiler or assembling tool, which takes your service called the Resources and generates in the B K file from those and installs it on your cold. And basically you're right. There is a total cold grader in any modern enjoyed project. Riddle is a bill to which is configured in a way that it knows where the source code is located, where resources are located and knows how to build your app independently from the enjoy studio. And this is very important because you can build your app not only from the injury studio but from the console. You can ultimate your build process, and you can, uh, you're free to do whatever you want in injury studio. You also have worried they'll tab where you can see all the available grateful tasks, but to make a good example of what is happening 100 hood off the run button, I'll demonstrated using a consult so you should be in the root directory of your APP. This is a common which grants execution permission toe the Great Deal wrapper script. Then you need to call a griddle. W assembled the Bach once built a successful you have your A P K files in app built outputs a pick a derogatory. You can use a DB to install their upon their poem A. The B stands for Android the Bug Bridge, which is a tool to communicate with your connected device or emulator. So we type 80 B in style that are for replace previous version off the app on your phone and above to your A p K fire. Then you can use a BB common with the activity manager to tow. Launch your app on the emulator or the device. So that's it. What is done in the background when you click run button from your enjoy studio. Besides that, Garrido is responsible not only for building can droid tap but also for independence and management. Let's open a great the great deal built pile not the top level, but the build fire off our module. So here you can see a list of dependence is which maybe 1/3 party libraries you're using. So if the library is in the repository you can add it to your project dependency. Just with that one line and great deal will download it for you. It's much more convenient than downloading Kleber is manually and placing them to the project. 7. Layouts - FrameLayout: to create the your eye for our main activity of of the list of no's was go through the most popular layouts. Android is suffering and compare their functionality to choose the most relevant. For our case. The simplest layout is a frame layout, which basically is a container, and in the most cases, it's used to hold a single view because it doesn't offer enough functionality to position we used in an efficient way. Let's take a look. You can see I have a friend layout with free buttons. Frame layouts with hate is much parent, which means that layout will take all available space. Another option is to use of rep content and layout will wrap around its views. Or you can define with our heads off layout or other element to writing exact value. For example, 350 maybe. What does the P will discuss later? But the piece does independent pixel. Most probably You don't want to use exact value because you want to support a Zeman e device devices as you can, so they have different screen sizes, so we'll stick with much burnt. You can see that we have free buttons inside of frame layout, but in the preview you can see on Lyford button. It's because we don't have any positioning in frame layout because it's very simple. It's very basic, and it's mostly used as a container for one of you. A few things you can do with the frame layout. You can specify layout gravity, for example, bottom and ah, this button will have grow at the bottom. And now you can see it's the bottom of the frame layout. Another thing you can work with margins. For example. I will spend why Margin left 50 dp for the second button, and you see we have a spacing here on the left, so basically, that's it. What you can do with the frame layout. 8. Layouts - LinearLayout: another where popular layout is linear layout. This is a lay of the syringes. Is Children in a single column or a singular or depending on the orientation? Orientation over the linear layout can be a vertical or horizontal. Another very important thing is that we use in building. Their layout can have weights. If you want to locate several views in the proportional sections, you can use awaits to achieve that. So let's take a look on the line there. Lay out. In practice, you can see a heavily in their layout, which takes the whole screen, and orientation over child elements is horizontal. We can change this orientation toe vertical toe, orange child abuse vertically. I have four buttons inside. Three of them have, with some Hayes right content, but one of them has her code that hate off. 80. Dp What you can do in the L in era layout so personable you can work with margins, the same as we did in the frame layout. Also, the important thing you can specify the gravity over the child feels. For example, I have said to gravity end, which are in just all the child views at the end off the winner layout. Another thing. You can use weights instead, off defining the hate off each element. So let's hear how it's working. Let's say I want this exact button to take all the available space with have so instead off defining hes I can define. Wait off this element when I define weight off the cell Ament. We don't need hate element anymore. So enjoy studio suggests, to replace it with zero DP. So now we see that our bottom is taking all the available space. It's very good because you don't need to hurt called the value because you don't know the screen off the device, which is used right now because it can be much bigger than you expect. So with weight, this button will take all available space. You can try to play with weights yourself because, for example, if you want toe if you want, Teoh have ah proportional size off two elements. You can add weight to another element, so you have free and for proportionally sized by their ways. Also, you can make one weight bigger than another, expecting that some off weights is one. So we have this button taking 70% in this 30% off this area 9. Layouts - RelativeLayout: and another frequently use layout is relatively out. It's our first functionality to position. It's child abuse in a relative position to each other and to the parent. Relative layout can be very efficient in creating complex your eyes. Is it to reduce nesting? Called the layouts? Is better to have let here Are he off the layouts? Because it's much more efficient in terms of your APP performance. Let's see how relative layout works in practice so you can see I have a relatively out here , which takes the whole screen and inside the URL to lay out. I have free bottoms well and you think you can see here. It's I D ideas, a unique identifier over the view within this layout, so you can refer to it. You can see that we don't have any positioning yet, as in a frame layout, but realty layout offers very powerful mechanism to position views inside of it. So let's try. I will try to align Parent arrived, so the bottom is aligned to the right side over the parent, which is a relative layout I want to set, but number two below, but number one So I am referring using the idea off the button. One. You see that this button is a link to the right of a parent, but no, but number two is below the button number one, and also I want to set but number two to the left off the button. Number one and I heard about number free and less right to position that in center off the parent. So but the number free is positioned in the centre off the parent, uh, and and then this Korean size, it will be located in the center. So what would not here in the where simple in the very simple way would be. Worry hard to achieve in any other layouts, for example, in ah, our layout or in frame layout. So relative layout is very powerful to if you need to create complex your eyes for your abs 10. Input controls and their attributes: to create your own enjoyed. You can use different types of simple controls. You can see a list of most frequently used widgets on the screen in that where developing, we're going to use text to use at the text menu items, recycler view and the floating collection button. Wilting Action Button is a relatively new region, and it's a part of 100 Zain Library. So let's take a look on the actual XML. So I have created the small showcase to show you different 10 droit widgets and their attributes in action. You can say I have a relative layout, which is a vertical one with left and right fighting off 16 to be. Please keep in mind that wedding is spacing inside off the layout or off the view, for example in. But I do have a parting cleft or 50 dp. So is this spacing and text You would have margin Top 50. BP is spacing outside of the view. So what happens if we said a budding top in the text to you? So you see, after a setting piling, we have another spacing insight off the element. Another attributes used Here you can see a background color, which is referencing color from the resource file. We have jalape sized and which are those free dots, which are showing that Texas too long. And it's not fitting in the text you. And it's because next year is a restricted with the max lines, which yellowing to show on the one line. It can also set an amount off lines here, for example, to or if you want to display all the text so you can just remove this, uh, argument. So now text is a wrapped by the text field, and old text is displayed here. Next element is added text here. I used to call him Color attribute and the reference the color from the resource file. Also here is a hint which ask Inc user, for example, into your name or enter your passport, and then user can type his name or password. Another view. It's a floating action button so we don't see fault injection bottom in purview. But it's because floating action button it's not a part off. Enjoy. It is decay. It's apart off android design library, as you remember when we discussed grade Oh, I said that unit, you can at the library center. Griddle dependencies. So we will do it right now. I open toe. Great deal. File off this module at that design library dependency. And now, when it's quick, synchronised now and we can go back and we'll see our floating action button. So now we can use this element in our 11. Supporting multiple screens: when you're creating conundrum that you need to keep in mind that you're doing with thousands of different device types with different hardware and so for configuration. In this lesson, we're going to focus on different screen sizes and screen densities. Don't forget to test your layout on different screen sizes to make sure that it's for sizing has expected. Don't use absolute positions and be very careful when you're using hard coded values. In the most cases, you're probably will using rep content or much parent values for view with and hates, as you remember when they have specified margins. Bad things on view sizes and Bruce examples a heavy use something called DP. The B stands for a density independent pixel, so let's try to understand what is density independent pixel and why we can to use just normal pixels. Instead, Screen can have not only different sizes, but also different densities. Density. The density is basically how many pixels are putting in one inch android divided screams by density in low dip a medium dp I hide FBI extra Hideaki I and extra extra Heidi pay scoring density is not dependent on the screen size, and Lo the past. Corinne. There are 120 pixels in the one age in high the past Korean. There are 240 pixels in one change, which is twice more So imagine you have to devices with the same screen size, but one of them has load the P I screen and another has hide it ice cream and you're drawing a square with a site with on off 120 pixels. It will take one inch on the loaded past screen and in Heidi Pair screen. The square will be twice smaller because one image on the Heidi Paris screen contains 240 pixels. Go away that we should use density independent pixels for DP. So when you're declaring cure layouts, you should always use DP to maintain same sizes across different densities devices. 12. Declaring layout for the Main Activity: in previous lectures have worrying about different types of layouts and your widgets an android. So we're ready to create a layout for the main activity on the screen shot. You can see already completed layout of the main activity with the list of notes from the database and floating collection. But as you see here, uh, floating collection button has a draw. Arable. Uh, so most probably you don't have this terrible. So I have great at archive with the drug balls you will need for the scores, and it's located in their resource is off this lecture. So please download this archive extracted open and durables holder, hoping all the stuff folders from it and placed them in their resource folder. You will have freed roubles and under age durable, you will have a few images for each density of the screen. Also, don't forget to add the support designed support library toe the to dependencies. As you remember, floating action button is a part of the design library, so you must have it to use floating action button. So now we're ready to create a layout for the main activity in the main activity in on create my food, which is called on Lee once when activities created there is a call to the set content for you on weapons and in parameters off this month. There, Issa layout a D layout. XML is located in Resource Is layout activity may. So the same name. Here you can see a layout, which is created by default by injury studio, but I will replace it with that our layout. So to make life easier, I have coping this layout, but we will go through each lying toe, understand what's happening here as a root element. I have frame layout, which is marching parent in with and hate. So it's taking all the screen. The second element is recycler view with the I D, which is activity main recycler view. I prefer to name ideas like this layout name and then name over the element to have unique ID's occurs that whole act. Then I have floating action button with a D activity main at button. Wait and hate is wrapping the content, and we have a gravity over this element. Both, um, and and so, as you remember, from layout, you can specify gravity off the element, so it's placed on the bottom of the frame layout and at the end of the frame layoff at the same time, would have layoff margin off 16 the B. So let's do the following thing. Let's breast out, Enter and extract Dimension Resource. Let's name this spacing, spacing media. So now we have our dimension extract to the Values folder in dimensions. File is good for the following purpose. Imagine that you want toe reuse this margin for the other elements. And in future, if you want to increase this margin, you need to do it on Lee in the one place in the dimensions holder. The same thing if you are developing, cure up for different screen sizes. So it's better to keep all your dimensions in the dimensions XML brother than heart holding them. And last thing is android resource, so it's ah, blinked toe that draw global, which is inside so toe point to the Drabble unit toe right at Drabble and draw global name . So as you remember, we have placed trouble here, so now you can use it in your elements. Depending convex screen density needed durable will be used, so if you will click control or it see him doing the Mac. You will see all the dribbles here with the different densities. So that's it with the cleric. The layout for the main activity so we can launch, are up and when it will be built, we'll see our new layout here. So, as you see, we don't have any more layout, which was generated by Andrew a studio. But have layout which would declared, We have floating collection button, which does not think of the moment. And we have recycler view, which is empty for now. 13. Activity lifecycle: before president with an old Sepp. Let's talk a bit about activity, which is one of the fundamental building blocks and enjoyed activity is an entry point for a user, and in the most cases, activity represents a single screen of that activity. Class takes care, creating a window and only think you need to do mystical, said content. Few method and place your your eye well already did it before when created the layout for main activity. Each activity has a life cycle and associated with it, like psycho Colback methods. When activities created on create method this cold and in the UN create method, you perform basic application startup logic that should happen only once for the entire life off the activity, for example, declaring the user interface defining member worry ables and configuring some of the why when the activity interest started state. The system invokes on start method on start cold eggs activity visible for a user as they prepare for the activity to enter the foreground and become interactive. For example, this Michael is a word that EP initialize is the cold that maintains the u I. When the activity interest to resume state it comes to the foreground and the system invokes on the resume. Colback. This is state in which that interacts with the user. The up states in the state until something happens to take focus away from that such innovate event might be for, for instance, are receiving a phone call. The user navigating to another activity are the device greenest earning cough when an interactive went. Of course, the activity enters the poor state, and the system involves the on post cold back. The system calls this method as the first indication that the user is living your activity . It doesn't always mean that activities being the story if the activity returns to the resume state from the post, state the system once again course on the resume method. For this reason, you should implement in the resume initialize components that you released during composed . When your activity is no longer visible to user, it hasn't her stop state, and the system invokes on Stop Colbert. It may occur, for example, when newly launched activity covers the entire screen. The system. My also call on stop when your activity has finished running and it's about to be terminated on the story method is gold before the activities destroyed. This is the final call that the activity receives. The system either involves this cold back because the activities that finishing do someone calling finished or because the system is temporary, destroying the process can containing the activity to save space. 14. Handling user interactions: this lecture, We're going to add a click. Listen, art are floating collection button. First thing we should do is to initialize vote injection weapon in their own create method of our activity. To do this, we're going to use find you by the matter where we should pass an I d off the floating collection bottom which we have assigned while creating layout for the main activity. As you see enjoy studio is underlying this line of code is because when you buy the returns object off the view class. But the class of are very able school think action bottom. But we know that this idea is belonging toa the floating action but in the region so we can cause the view to the folding action button We have our floating action button object So now we can add a one click listener to the object Go at the click listener. We should call second quickly snore method and passed a za parameter an object of a class which implements interface on click Wismer. Let's create an animal's glass off our quick listener like right here we're typing you quick in control, less space and with a little help off the powerful out to complete creating a click listener now in on click method, which will be cold. One button is clicked. You can handle the logical for that. 15. Starting new Activity: when the bullet infection. But in this clip, we want to start a new activity. Were user will enter title and the text of the note before starting an activity. We need to create it first. So less quick. Right mouse button on the package where we want to create an activity and select you the activity than empty activity. Let's name it note at activity. You see the tender. A studio generates layout for this activity as well. Let's click finish. So we have note at activity class created as well as layout for this activity. Besides that android studio additon entry toe the android manifest XML file which must be there. If you're going to use this activity in your app now, we can start its activity An android. To start an activity, you need to use intent. Class intent is an object that provides Ryan binding between separate components such a stuck divinities. The intent represents an app intend to do something you can use intent for a wide variety of tasks, but in this lesson are intent ones will start a new activity when you're instance creating a new intent, you need to pass a context and the glass over the activity you want to start after that, you should call a start activity method and bus. Our intent is a parameter. Now we can run our app on the emulator and see it's actually working So quick. Floating collection button on the mind screen and new activities launched, and I see those small things here. First, I want to have a title, which says New Note and also I want to have a bag button. So let's go back to our code and fix this. When they open an android, manifest ICS a mile and modify our notes at activity entry. I will add another attribute cold label, and we'll ride the name off the activity at this moment. Let let's think for a minute what will happen if I want to dress late my app into different language, the support localisation, even if you're developing that for a single languish of the moment, you should extract your strings for the strings XML and referenced them. So let's go to the strings. XML and Great on entry for the note, add activity label. I will make a key activity name, new note and the activity name will be new note. No, I will go back to the manifest file and instead of heart holding the name of my car referenced Oh, the string resource by typing at string slash string i d, which is activity name New note. This is a good practice to keep all your strings in a strings XML We also wanted to add a back navigation to the activity. One of the ways of doing it is to specify parent activity name, which is main activity was started that once more and see the results. So let's with full of the injection button once more and we'll see that we have our changes here. Have a title, you know, and we have bag Bokkelen when she can't click and get back to the main screen. 16. Declaring a layout for the AddNoteActivity: this lecture. We're going to create user interface for the ads. Note activity. As you see from the screenshot, we should have to edit text one below another where the 1st 1 is meant to be a title input filled with a hint title, and the 2nd 1 is the notes, text input and has a hint interior text here. So let's go to the activity note at XML, which is a layout file generated by in Very studio and modify it according carbonates, to say our time. I'll cope with the layout and we'll go through the coat together first. You can see that that heaviest Lynn their layout with a vertical orientation is our play out. I have also specified bedding off 16 b, which actually is a reference to the dimensional resource which we have created for the float injection button. Next, I have added text with the I D activity note add title, and this at the text with is my Shimla parent because we want to take all the screen with we have restriction to the one line and input type is text cap sentences, which means that text will be capitalized after the dot as the sentence is finished. As I want to have a hint, I will use hint attribute to specify a hand title and I will use out Bless Enter key shortcut to extract this drink to the resource is file. I will name it activity note. Add title Hint Because I have decided to keep this naming convention to add activity name and then a string name to avoid collisions. If, for example, I will I will have ah title hint in another activity. It's better not to reuse drinks as their translation made the herd depending on the context . I also want to specify a text size off the title I'm using text size had tribute for this. As you see for the text size, I have used SP, a speech stance for a scale independent big. So this piece scale factor depends on the user setting, and the system scales the size of the same as it does for the DP. So when you're specifying text size, you should use a speed instead of BP as well a spotting. We will extract excise to the dimensional resource file by pressing out bless, center and entering a resource name next sighs guy, so let's do the same. For a description filled, I led the hint. Enter your text here. I'll extracted toe the resource with a key activity note at description hit. Then I let a text size off 15 SP, which I will extract a resource while with the key text size description. So, basically that's it lets her on our and see the changes this week for construction. But undermine activity and then you note activity resulting. So you see, are you here? You have a title at the text and that at the text for X corruption with machines were have specified. So let's try to enter a title and thanks. I see one thing here I would like to change when I'm opening a soft keyboard are at the text is not adjusting to it. So when they click on this had the text, the keyboard appears on top of the at the text. But I would like that that the text changed it. It hate when keyboard is opened, so to fix this is go to her manifest file and at a line there are no Ted activity Windows soft input mode adjuster size after this. Let's try toe around that and see what happened. Let's go to her, you know, to activity. And you see that when keep work is opened at the text with the description is resized. Accordingly. Toe the available space when they closed the keyboard and the text is a precise accordingly , toe that whole screen. 17. Creating a menu: in the toolbar of the noted activity have a done button. We should save our no to the database for all menu types. Android provides a standard XML format to define menu items. Instead of building command. You in your activities cold. You should define the menu. And no, it's items in that extra mile menu resource you cannot. You can then inflate ammonia resource in your activity, so let's create them when you're resource. For the note at activity, please click. All right, most button on the resource folder. Then choose new an Android Resource directory and the dialogue. Choose the resource that menu and click OK. Then find a created menu resource holder. Click right mouse button on it and choose new menu. Resource file Wasn't Put your menu file name to maintain a consistency in the names I'll name it May new note at and click OK, After that, you cannot an item in your mind you for the convenience alco p the item, and we'll go through the cold together. If you have a show as action name Space underlined, please click out Bella Center and at the name space to the extra mile as you see, we have a manual element and item element inside of it. Menu item, hasn't I d. My new note at done to reference it from the Java cold in the future. Also, Atom hasn't Aiken, which is one of the durables who have added to the project fruitlessly show as action. A room means that I can will be shown on Lee. If there is a space for it in a toolbar. Another case you will see a free dots. I can. A drop down menu is this Behavior is handled by Android by D Cold. You can see the tenderly studio Under Alliance an item element, and say is that the menu items should specify a title. So it's best if I a title for that menu item. I am, I think, a title attribute to the main Your Item and typing Done. Let's extract the string to the strings XML and type of resource name menu note. Ed Done. This title will appear in a drop down menu. If the menu item is not fitting in the action bar, we have the kind of my new XML, so next step is to display. I mean, you're in activity. Let's open note at activity cold. Display a menu from the XML. We should override one of the activities methods. Let's click control plus So and find great options, menu method and quick. Okay, so in this method, we can inflate our XML resource toe, the main your object, which were received as an argument in this method. To do this. Let's define minions later and cold. Get Minion later methods to get an instance off the inflator. Many inflator is a class, which is used to instance she ate Menu XML files into many objects. Then let's go on inflate my set on the inflator object and bust perimeters. First parameter is a menu resource i D. And the second perimeter is a menu object, and we should return true for this menu to be displayed. No, let's run that and check what would have. Let's go to our note at activity, and we can see that we have a menu with Dan Bottom. But this bottom is not doing anything in the future. This battle safe are no to the database, but as we don't have database yet, let's add a quick listener and will display a temporary message. Let's go back to our note at Activity Coat. To add a quick listener to the menu item, you should override another method. Bliss. Quick control less so and fine on options item selected method and click. OK, so this is a place where we should handle a click every event for the convenience. I'll past based a code snippet, and we'll go through it together. You can see that I'm using switch operator to check selected menu item I D. And if ideas menu note at done, I am showing a toast, which is a small folding message, and then I am calling finish to finish this activity. When we will add a database star, we will get back to this method. But now let's run our and check the changes. Let's go for a note at activity and let's quickly done button in the toolbar. As you can see. When a quick done button activity was finished and the temporary message toast was displayed 18. Defining a data model: one of the main features of the note. Sepp is ability to save nodes in this section will define the data model and implement a temporary in memory data storage. The good thing about this approach is that we can postpone the decision about choosing persistence technology. It's a very small bit in a note step, but imagine if you are working on a large scale project instead of working on the person. It's persistent. Straight away, you can implement a prototype with the in memory data storage. So first, let's define our data model with with the right most bottom on the package where you want to create the class, choose New Java class and her name off our model object. L name it. Note. After the note glasses created, Let's add the fields. So the first thing when it is a unique identify off the note Less great and I d field with a type long. Also, our note has a title and a description. Let's add those still filled star class. We're going to store text, so type of those who fills history was generate getters and centers for the pills, click common bliss and and choose get her since centers so like all the fields and click OK on your machine depending on the platform T shirt cuts may differ. So if you are not on the Mac bliss, click Health and came up reference to check with short goods you have knowing shortcuts will significantly improve your performance in the future. Another thing I want to do is to create two constructors with a B and without I d field. So I'm clicking Common plus span, selecting only that fields and clicking. OK, I will create another one constructor without I d Field. Because when we save our old, we don't know the idea off this note yet. So where that we have defined a data model for our note. 19. Creating a datasource with the in-memory storage: Let's create a data source within memory implementation to temporary. Keep our notes. After this, we will work on the rest of that functionality, and there's the last step will implement our real database and swope the in memory implementation with their real one. Let's create the glass and call it notes data source inside of the class. Less great free methods. Safe note. Method To save the no to the database, get notes method to get all knows from the database and the league note message to do a specific note from the database. AL. Copy the code snippet and we'll go through it line by line. So it's in a memory implementation of the database. As you see, I have a static dream up, which I have called notes map, and it's my pink notes i d to the note object. It's static, and it's associated with the Notes Data Service Quest and not with any specific object. And it's initialized only once. When notes knows, data service class is loaded into memory, we have saved note method where you were, you should pass the note object and the method you can see a temporary in memory safe method implementation I'm generating can I d for the note and putting it to the static map . Second method is get notes method, which returns a list of notes, and the 3rd 1 is though it note method, which accept a note ideas a parameter and removing note from the map. So that's it. We have our temporary in memory data source implementation, and we can use it to store our notes. 20. Splitting packages: before we proceed, let's make one small, non functional improvement. As you see, we have all our classes in the package. Come my company notes. So we have to activities, data source and their note model. So those two glasses all are two activities. Are you? Eye glasses below stew are responsible for the data, so let's split those glasses by packages. I'll create one your package where I will move our main activity class and note at activity class. And let's great another package and call it data this quick right mouse button. New package. Let's dive data. Okay, and let's move our glasses. Note and note data source toe the data package. So that's it. Keeping classes in the right packages improves readability and navigation in the in your project. 21. Saving a note to the in-memory data storage : as now we have our data source and note at activity with the done button. Let's implement the functionality off Saving Noto the database. Let's open note at activity and add No, it's data source field. We can initialize data source in the UN create message off the activity, which is called on Lee once when the activity is created. Another thing which we need to do before saving no to the database, is to get title and the description off the note from the editor Tex For that purpose, let's define another do filled title at the text field with dive at the text for the title and description at the text with the type at the text for the description, let's initialize those fields with. Actually I we just from the layout, so I use find view by deed to initialize my title at the text and description at the text. After this, let's create the private safe note method, which takes no arguments on the return sport. In this method, we will get text from the title at the text and from the description at the text, then will create a note object and save it to the database to do this was the point local variable title with a type string and initialize it with the string from the title. Edit text by calling title at the text. Get next two straight. Let's do the same with a description I am defining. A description were able and assigning to it a value from the description at a text. Now, using title and description, I can create a note object. So was defined Ivory able called New Note and best title and description as the parameters . Next, we can take our data source Object and Cole. It's safe note method and passed a note object as a perimeter. So let's go. Are safe my food in the done button Click listener instead of showing toast. 22. Initializing RecyclerView layout, separators: we have implemented saving no star in memory data store functionality. So next step is to implement. Note. Liz displaying functionality In one of the previous lectures we have created, I write for the main activity where one off the widgets was a recycler view. So let's take a closer look on what their site or view is and how to start music It Recycler view is a container for displaying large data says that can be scrolled to our efficiently by maintaining CA limited number of use. To use the recycler view Egypt, you have to specify an adapter and the layout manager layout. Manager positions item views inside the recycler view and determines went to reuse item views that are no not longer visible to the user to reuse or to recycle of you. Layout manager. My ask the doctor to replace the content off the view with a different elements from the data set. Recycling recycling Proview's in this manner improves performance by avoiding the creation , open unnecessary views or performing extensive point of view by deal lookups. So let's initialize or cycle of you in the main activity code and add a layout manager to it. please open a main activity class and let's define the private Lipper Cycle Review field. After this, less initialized are a cycle of you in the own create method. For the convenience. AL. Copy a code snippet and we'll go through it together. You can see the time using fine view by deep to get the recycler view object from the layout. Next I minced Enshi ating ill in their layout manager and setting CA vertical orientation. This this layout manager is responsible to show I comes off their secular view in a vertical list. Then I'm setting this layout manager toe are recycler view. On the next line, I'm creating divider item decoration. It's a divider line between items in our cycle of you. I am calling at item decoration on the recycler view object and passing our divider object as a parameter 23. Creating RecyclerView item layout: in order to display items in the Recycler View unit. Have an adapter, but before creating conductor less Graito layout for the item. Quick right mouse button on the layout directory where all other layouts were located. Select New and the Resource file. Enter a name of the layout. I'll name it. Notes. List. Row After a finalist parade that was Declare our layout. I'll copy a cold. Snap it and we'll go through it together as the root element. I have a vertical linear layout. It's clickable and has a background selectable item background, which is an attribute reference from the Complaint Labor Library. Also, I have a parting off 16 dippy, which is a reference to the dimensional resource. So now I think you can evaluate the benefit of extracting dimensions to their resource is we're using it for the first time, and it helps us to maintain some consistency across the whole app. Inside of the leaner lay out, I have to text you elements. One is for title and another one is for description. Both text use are limited to a single line only in text use. I am also were using a text sizes, which we have used in the layout for the ad note activity once more. Think you can notice here for the attribute text were using tools name space instead of android name space specifying those text attributes makes enter text visible only for a developer in the preview window. If you will run that text you with two stacks attribute will appear empty. But you can see how your design will look in the development process, which is Americans convenient. We have great that they lay out for the item, and now we can use it in our recycler view. 24. Creating an Adapter for the Recycler view 1/2 (ViewHolder): we have a recycle review layout manager and the layout for the list item Now to display beta in the recycler view. We need an adapter at that. First, provide a binding from the APP. Specific data set toe views that are displayed within a recycler view. So let's create one right now. It's quick on the your I Package New Java class and let's name it notes list adopter and click OK after the classes created, we need to extend an adapter class. As you can see, adapter is a generic less, and to use it, we should specify glass, which extends beholder. Class A doctor implementations. Should subclass view holder Purgation potentially expensive? Fine view by the results. So let's create the Southwest off a view holder. Well, they find it inside of that doctor class. Alco pickled off the view holder and will go it through it together. View argument and the constructor will be l. A. Out over the list item which, which is notes List Earl XML. So idea over the view holder is to create a class for a view which will be reused by a doctor instead of cooling trend view by D. for each new item in the list, which may affect your performance. So on this quest we're just initializing filled with the bridges from the item layout. Now we can use this glass in our adopter signature. We need to specify a full name because it's a in our class. Let's press outlets center to result Adapter class. It is a Napster class, so we are extending it. We should implement all its methods, less breast helpless. Enter again the unemployment. My foot's in the dialog books. We can see all my thoughts we should implement. Let's select them all and click OK. 25. Creating an Adapter for the Recycler view 2/2: and previous lecture was started implementing for cycle of your doctor. We already have notes list, adopter class and beholder. Inner class. But we need to finish implementation off the notes list of pepper. First method we should implement is uncreative your holder on Create the holder method should return object off the View holder Note item that we have implemented in previous lecture. Second this on buying a few holder, which is gold by recycler view to display the date of the specific position and the 3rd 1 is yet item count, which should return. Count off the items in the data, set a copy of the implementation and we'll go through it. The first thing you can see that they have defined the constructor which accepts notes list as a parameter, and I have assigned it to the notes list filled. You don't create beholder method. I'm instance she ating view holder and passing in a constructor. The view object which is inflated. No cholesterol layout. We're already used inflator and add notes activity to inflate a menu object from the resource file on buying for you. Holder shouldn't bind the data on the specific position toe the view holder. As you can see, we have two parameters. 1st 1 is a view holder, and the 2nd 1 is a position. So we're getting a note item from that note list at the specific position we received as an argument and populating for you. Holder with the actual data, all the logic about went to reuse or want to create a new view is handled automatically and get item count would just return a note with size, As you can see, besides all the mandatory methods, I have implemented one extra method, which is set note list. We will use this method top date. No list in the existing conductor when away, for example, do it or creating you. Note. After assigning a new note list, I am calling notified A to set Changed, which notifies that. And if you're reflecting, the data should refresh itself. So now our adapter is already to display notes 26. Displaying data from the DB in the RecyclerView: we have created notes, list a doctor and implemented all the native methods. So let's said the adopter to the recycler view. That's great. Private notes list a doctor filled unless initialize it and on Create my Foot. But we'll hear one thing missing here. We need the list of the nose to pass into the constructor and as we want to see in the list all the notes safety in the database. Let's get the notes from the database and passed them to the constructor. As you remember, we have our nose data source with the temporary in memory storage implementation. So let's great private knows data source filled and initialized it in the own create method . After this, let's great private list off notes field, and then they shall eyes that with the list off the notes from the database. So we're writing notes, a sign and calling get notes on the notes. They deserve subject. So now if but have any notes in the database, we should have a populated note list, and we're pricing this note list in tow adapter. So now we can call a recycle review, said adapter and pass adapter object as a parameter. Now, lister on the cold, it's and see what's happened. So as you can see, we still don't have any noting the list, even despite the fact that we try to add a few notes earlier. The reason is that instead of having grilled database, we haven't memory implementation, which is holding data in memory Onley. While you're using that, if the process is finished and you are starting that all the day's lost. 27. Returning a result from the Activity: before in memory databases always empty on that upstart. Let's try toe. Add a note. I'm going toe the ad note activity entering Cup title and the text and I click done, and I still don't have any notes. So I think you already know what's happening. We're getting knows from the database on Lee when mine activities created. But when we have the new note, mine activity doesn't know that note is added, and we should try to get nose from the database again and update the list with the new notes. So let's go to the main activity code and fix this issue. To fix this issue, we should be somehow notified from the noted activity that we have clicked a done button. This can be achieved by returning to result from the notes and activity. First thing we should do is to change start activity method called toe start activity for result massive call and in start activity. For result call, we should bus a second parameter, which is a request cold parameter to identify the activity that is returning results in the future. Instead of hard coding and value, let's create a constant, so I'm typing private static final end note at activity. Request cold and assigning well you want to it and let's past this constant as a parameter in the start activity for result cold. The second thing we should do is to receive a result from the note, said activity. To do this, we should override on activity result method police breast control, plus old or go to the menu and select code override methods and find on activity result and click. OK, we'll have free arguments. First is a request gold, which is a code where pressing and start activity for result as a parameter. So by the school we can identify activity which is returning a result second is a result cold. A result coat is specified by the by the second activity. This is either result okay, if the operation was successful or result canceled if they use are backed out or the operation failed for some reason. And the last one is an intent that carry a result Data Elko P A code snippet in the method by day and we'll go through it together. And the first line we're checking the operation was successful. The second line we're checking is the result coming from note at activity by comparing Kirk West code in the argument with a note at activity Request Code constant. After this, I am Reloading knows list from the database. Updating notes list in the adopter and scrolling core cycle Review to the top. Now we should go to the note at Activity Coat and return a success indicator. If the done button was clicked, let's navigate to the code responsible for the handling Done button, click and after the coal to the safe note method and before finish method gold. Less goal activities said result method with parameter result. Okay, that's it. Let's run that and try it again. I'll open no Ted activity and we'll try to add a note once more. I meant drink, I tell in the text and clicking done bottom. So as you see now, we're here one element in our list. Let's try once more, and another element is in our list. So now let's start in the in memory database 28. Define a schema and a contract: where they have most of the functionality of the notes up. We can Agnos to the database and get a note list from the database. The problem is that we have in memory implementation of the database that this persisting data on Lee while the APP is running a Souness processes killed all the data from the memory databases a raced. So we need to create a real database implementation and swap the in memory implementation with the real one. One of the main principles of their skill data basis is the schema. A formal declaration off how the databases organized the scheme is reflected in the SQL statements that you used to create your database. You may find it helpful to create a company in class known as the Contract glass that explicitly specifies the layout over your schema in a systematic and self documented way. It was great, and you class in the data package and call it knows the big contract and let's be clear, private constructor, just to make sure that no one can instance she ate this quest. A good way to organize a contract quest is to put definitions that are global to your whole database in their oath level of the glass, Then create an inner class for each table that enumerates its columns. So we need to create a glass that will older present a table where we're going to store our notes. I'll cope with that class implementation, and we'll go through it together. I have called this glass No. 10 tree and, as you can see it implements based columns interface By implementing the base columns interface you're in their class can inherit a primary key field called Underscore I D. That some classes that some android glasses will expect you to have. It's not required, but this can help your database work in Germany with the android frank work in this glass, I have only free constants. First is the name off the table in the database. Title and description are constants that are representing column names. We're going to store no title and no description. That's it. This glass will help us and further database implementation 29. Create a database using a SQL helper: Once you have defined how your database looks, you should implement methods that create and maintain the database and tables for this purpose list. Great and you class in the data package and goal, it notes the B helper. Then we should extend a skill like open helper. As you can see, class declaration is now underlined. It's happening because a skill like open helper is an abstract class that requires us to implement two methods on create and on update. I was Let's quick outlet center and implement. Those methods can create it's cold when the database is created for the first time. This is where the creation of the tables and the initial population of the table should happen on update. It's called when the database need to be upgraded. The implementation should use this method to drop tables at tables or do anything else needed to upgrade to the new scheme. Aversion Alco pair. Snip it off the court with the skill statements that will help us to create and drop a table, and we will go through it together. As you can see, I have a few constants Defiant. First is a database version that you used in the database migration. Then we have database name and a few helper constants as database text, data type and coma. And we have two constants that represent a scale statement to create a table and drop a table. I have also declared the constructor, which is going a scare light, open helper constructor with the database name and version in parameters. So now let's implement on create and on update methods as we already know in and create. We should create our tables in the arguments of the method. We have instance off the Ask your light database. So let's call exact SQL method on the database subject and this parameter. Let's pass a statement that creates a table. As we don't have any specific database immigration, we'll just drop and recreate a table in on update method. So I'm calling exactly scale busing. Drop table statement is a parameter ankle and create method afterwards. So this it we have created our SQL light database 30. Swap in-memory implementation with the DB: a naturalized database relate. The task is to swap in memory implementation with the rial database implementation. Let's open knows data source. Glass and the Lincoln Memory implementation Next was defined. A private knows that the helper field and less great constructor, where we will initialize the notes. The big helper two instance she ate knows the big helper we need to pass. A context is a parameter. So let's add context. Argument in the notes they deserves constructor. And then we can pass it toe the notes. The big helper constructor. Okay, now we need to implement our methods. Safe note, get notes and the live note. Implementation of this method isn't complicated but requires for, I think, a lot off boilerplate cold. So I'll cope with the implement. It implemented methods, and we'll go through them together. Let's look into safe note myself. First, we're getting right herbal database from the helper. Then we're creating a content values object, which basically is a key 1,000,000,000 map. Were keys are column names. Then we answered values to the table and closing. Could they be in the get notes were creating empty note list where we're going to store our notes, get incredible database and creating a projection, which basically is an array off wheels. We want to retreat from the database. After this, we're making a query to the no stable where we're passing this projection and ordering knows by descending by the because we want to have a new note on the top of the list where he might have returns, of course, or object. Coarser is an interface that provides access to their results that returned by the database query. So using this coarser, we're moving through the data set, getting values from the combs, creating note objects and putting them to the notes list. After they're no more items, we're closing the coarser database and the returning consult list. Delete notes. Method receives a note idea as an argument. We're building where query, creating an array with the values for the query and calling the lid method with all the needed farms. After all, where closing condemned the base. Now I have a real database implementation and let's try to run that, and we have compilation errors. It's because we have added an argument to the constructor. But everywhere in the cold, we're trying to call a constructor without passing kind of thing. Let's fix Let's fix it and bust a context in the constructor in Maine activity I can. Plus this in the constructor as activity. Is the context the same. The same list within note. Add activity. So now we can run that again. Let's try to create a few notes. So a quick exploding action button attack Title one and text one and click done button so we'll see are no appeared in the list. Create another one note with the title two and text to also appearing on the list. No, create another one note as you can see your nose harboring on the top of the list to make sure that our database works fine. Let's kill that process and started that again. So as you can see, our nose list is displayed properly. So our databases, working as expected, 31. Creating a NoteDetailsActivity and declaring layout: now note. Step is working properly with the real database implementation, but we're missing detail screen where we can reach full text and a little note. So let's create it. And if you want to challenge yourself, try to pull this section on, pose and created by yourself and then compare their results. Another case. Let's click with the right mouse button on the your I package and creating your activity called note details. Activity after activity and they slay out dis created Let's open activity no detail. 60 mile and the glare are you are first for the convenience. I'll pass the layout, and we'll both go through it together. As you can see, it's very similar to the notes. Add activity. Layout difference is that the layout is placed inside of the scroll view toward inability to scroll the view if the text is too long. Another think you can see is that instead at the text, we have text to use for title and further description. All the headings and text sizes are used from their resources. Layout is already and we can write the cold 32. Add click listener to the RecyclerView item: to open a new activity with no details. We need to handle a quick even to national turned a list. To do this, let's create a new interface in the U F package called a Node Selected listener. In the bother of the interface, let's define the method unknown selected that takes in the parameter snows object and returns void. Then let's open an old list adapter and ed at all. Note selected listener parameter to the constructor, then click out, plus center and select Create filled for parameter and click. OK, as you can see, a note selected that listener field is created and initialized. Now let's navigato that on buying beer holder message and set on quick listener to the whole item view to do this. Let's right holder that I don't view that so set on click Listener and let's create on an animal's quick listener object. Actually, I have a click listener for our note item, and we head note object so we can start activity starting out activity from here. But we will not do it. We will handle start activity logic in the main activity, and for that purpose, we have created a note selected listener, Let's go or not selected on the unknown selected listener, object and person note is a parameter and as noted success from the inner class, it should be declared this final. The reason why we're in a starting activity from the doctor is to make our gold more maintainable. To start a new activity, we need to have a context. So if you want to start it from a doctor in the past, the context and the doctor and the result you will have your urologic spread all over the glasses. Another one reason is to make this adopter usable. Imagine you want to make another one screen where you want to display same note list. But instead of hoping income details activity on the item quick, you want toe show No details in the dialogue. So if you have your click listener that opens an activity defining the doctor, a doctor will lose this flexibility so you can consider this approach is a good practice. Now we can go to the main activity and create a new anonymous glass that implements a on notes selected listener in the doctors constructor. And here we will arrive the Coto launching activity 33. Passing an object into the NoteDetailsActivity: no, as we have. Ah, no title. Quick listener. We can start to know details. Security as we want to display selected notes. Details in the activity we need to pass there a note that was selected by user. First, let's go to the no details activity and define the public's during constant with the name note extra. Let's die public static for I know string note. Underscore extra and let's assign a value off note extra toe. This from stuff. This will be our key for the allergic that we're going to pass to this activity. I prefer to define the ski as a constant and activity where the user where the object is best instead of hard coding it. So looking at this definition well already, understand that this activity might have an extra object. Let's return back to the main activity. Never gate to the notes selected listener and create an intern to start in your activity. So I'm writing intent your intent, get context and passing a class off the no details activity. Next step is to person no object to do this. When it took out a put extra method on the intent object this method except still parameters. First is the name of the extract, and for this purpose we will use the constant that we have defined in the no details activity. So I am typing no details, activity that note extra, and there's a second parameter. We need to pass the note. And as you can see, this land is under Reliant as an error. The reason is that this method is not accepting, can object. But there is a solution, this method except Ciruli Zobel and possible, as you may know, that glass that implements a realizable interface maybe serialized in this serialized only thing you need to do is to implement a serial Izabal interface. But we're not going to use a realizable in this case, because Java uses reflection for serialization and the serialization off the object is better to avoid the reflection in Android as it as it may slow down your performance. Instead of Cyril Izabal, we're going to use possible. It's writing and restoring object state from the parcel. It requires a bit more implementation with the most off. The most of it is handled by Androids Studio. Let's open a note object and implement a parcel Herbal interface Glass signature is underlined because we need to implement on interface methods. So let's quick out the center and implement old in its methods. After this, no glass name is still being conned, relying Let's navigate toe the note glass and quick out. Bless center again and select Add Barsa ble implementation. That's it, Andrew. A studio done all the work for us. Now we can return to the main activity and check that line is not under allied no more. No, We can call, start activity and pass in an intent. No, it's open and no details activity and implement the second part. As you remember. Would it put the note object in the intern by calling Put extra Now we need to get back then or object from the intent was defined the local notary able and initialize it with the object from the Internet. Dexter, by calling get intent, get possible extra and passing the extra name, which is our constant note extra. So this is a way how to pass an object from one activity to another. Now I have the note object in the no details activity and we can set no title and description toe the your I Al Copia called snippet, which transfused and said text Tow them. Now let's run that and check what we have. No, we can quicken old tight. Um, and see that note details Activity is displayed and we see are no details are no title and are no description. So that means that our object is passed to this activity. 34. Creating menu: Now you know, details. Activity. We need to create a menu with the delivery button. Let's navigate to the menu resource holder and creating new my new resource file. I'll name it my new underscore note. Underscore details. Next. Oh, great. An item element. Then I made Inc an idea tribute with, Well, you. My new underscore note underscored details underscore daily. Then let's said a really taken to this item. Put a title believed press on the center so it extracts during the resource and give it a name. I'll call it menu Underscore note. Underscored details underscore DILIP and the last thing we should specify is a show, a section attribute and they said to send the value if rule when you re sources done. So let's move to the no details activity cold as you remember when it over right to methods . Want to inflate the menu and another toe handle item clicks. I'll copa both my says, and we'll go through the code as you remember. We've done the same in their note at activity. The only difference is the menu layout in the menu item I D. So let's run that and check the changes we made. Now we can click a note item and seasonal detail screen with the new menu item, which does not think of the moment. 35. Confirmation dialog and delete Note functionality: now one toe handle the Littman. Your item. Click. So when user clicks and do it, man, your item Want to present the user a dialogue were intended to confirm a delish in action. So I'll copia code snippet and we'll go through it for this purpose. Over displaying Cut that I looked at the user were using the alert Diallo the first unit to create the builder. And using this builder, you can call different methods for example, to set a title to set a dialogue message. Ah, positive bottom and ah, click listener for this positive button as well as negative button as you see your title message and buttons by reference Resource is from the from the strings XML So for this lecture I have created resource is with this ideas I'm referencing for the title, for the message and for the bottoms. Now we need to complete action when the user clicks. Okay, so we need to We need to have, ah, our database and coal to make a call toe the little Nell's. So first, let's create ah priority field. No, her notes data service. And let's initialize it in the create method, your campus Ah, context, which is this activity? And then this next think we're need to have is a no tidy. So let's great another one filled, which is long and name it. No tidy. So as we have a note here, we can get a no tidy from the nose. So when user clicks yes, that he's confirming the action. You can use our data source to delete a note and use a no tidy now to refresh our list on the main activity, we need to set a result, and we can finish our activity. That's uncommon showed the lead I local when user quicks the billet menu item. And as you remember to make this work to refresh a list when item is added or deleted, we need to go to my an activity and instead, off start activity called start activity for results so less I'm calling historically with the result and the next parameters should be a request cold, so I'll create another one constant, which will be a instead of know, Ted note details, secretary request code, and there was sign to now I can use this request called and start activity for results, and when we received our activity result. We're checking. If that request gold equals activity, note at activity. Request cold then we're refreshing the list. But here we should add another one. Check that if the request code is note, details, activity, request code toe refresh notes as well. So I'm writing or we're request. Coal equals no details. Security requests called. So if any of this Constance is our request code. So we're doing this performing this actions so we can run on the app and see how it works. Let's elect on those item from the list. Then let's quick a delete button and confirm a no delish in. So is the C note was deleted from the database and list was loaded from the database. So are no disappear. So do Ishan. Nationality is working as well as all the functionality off that is ready, and we're ready to publish it toe the Google Play Store 36. Release to the Play Store: build a signed apk: we have been a step functionality development and we can publish it to the store. Publish app to the APP store. We need to build a signed A p K file to build a sign that the K file when it to navigate to the menu, build and select a generate science A PK next one it to select our module. We have the only one module in our Then we should quick next. Here. You should create your own key store to do this unit toe quick, create your bottom and feel all the details. Then you can quick. Okay. But as I have already key store created, I'm just feeling I'm just selecting the my key store and feeling that the details No quick Next which was a bill type, which is a release. And we're shaking that we're signing this file with both signature versions. And look, look finished. No, we wait while EP is being built on build process is finished. Became clear krill and Flender and you will see that police a p caid. Now you can goto the Google play store. They are developer console and select this file and publish it Lepley store