 So good afternoon, everyone, and welcome back. So this session is going to be about Android SDK and how to build a viable app at SQL using the SDK. And I'm going to do this session from the user's perspective and based on the experience that we have acquired by building this application called DNMS, which stands for District Nutrition Management System. So this is a community application which where the public health midwives use this application to work from toe to toe, where there are children under age five and track their nutrition states. And then they use this application to report those information back to the main DHS2 server so that DHS2 users and people who are in the administration level can analyze those data to take decisions to improve the nutrition states of the children. So that's the primary use case where we had user Android SDK. So for this session, we also have some prerequisites if you are interested in following the hands-on exercises. So the first one is you might need to have Android Studio installed on your system. And the second requirement is to have an Android Emulator installed or have a supported Android device so you can test the application while we are doing some exercises. And this session is mainly is going to be about the DHS2 Android SDK, as I mentioned. And most of the exercises and the demos that are going to be shown in this session are going to be based on Java and not Kotlin. And I want to highlight that it's not a workshop about Android development. So it's purely going to be about SDK and mainly about the functionalities of the SDK. So Android SDK, if I want to give a short description about the SDK, it's a common good that allows you to work offline so you don't need to have an internet connection once you develop an application based on the SDK. And the SDK is capable of communicating with the DHS2 instance when you really want to synchronize data. And so obviously it facilitates the development of Android applications based on your custom requirements. So this is a high level overview of the SDK. So it kind of acts as an mediator between your application or the DHS2 core application and the DHS2 API. Basically, it allows you to communicate with the remote DHS2 server via the DHS2 API, but you don't have to really work on the DHS2 API directly. So you can just call some job and that's do whatever you want to do with the API. So what if we simply use an HTTP library or a database? So this is how we kind of interacted with the DHS2 servers before we had something called Android SDK. So during that time, we kind of had to manually handle authentication and if we want to support multiple users with the same application, that was really, really hard as well. And we also had to manually manage the databases. Like we had to create and define the relationships, write queries to access data, and also manage the data states, especially if you want to synchronize the captured data with the remote instance, we had to keep those states, whether the data has been newly created, whether the data has been already synchronized with the remote server, those kind of states, we had to kind of manually manage them. And also, if DHS2 new versions come up with new features, then we kind of had to go through them, go through the documentation, and manually update the Android application to support those new features. And the hardest of all is handling offline online status, as I previously mentioned, so there can be many, many complaints in the data. Like if someone added something on the application and if the same thing has been edited on the remote server, so we kind of had to manually resolve those conflicts, which was not an easy task. And also, the last thing is we have to keep everything in sync with remote server because there can be so many changes that's going on on the remote server, like changing metadata and also changing data. So if there's no SDK, we have to write a lot of code to keep these two instances in sync. So let me quickly go through some of the key features of the Android SDK. So the first feature is the metadata synchronization. So metadata is what kind of defines and DHS2 instance. So it includes things like programs, program sections, program stages, and so on, especially track entity types, the program attributes. So there are many, many metadata in DHS2, which kind of uniquely defines and DHS2 instance. So if you want to work on the same instance, there should be a copy of the same metadata in the Android application. So this is kind of supported in the SDK, so you don't have to worry about calling hundreds of APIs to do the metadata synchronization. And the next one is about data synchronization, which is kind of an obvious requirement. So once we have metadata, so then we can create new data based on those metadata and those data should be synchronized between the remote server and the Android application as well, so that is also supported. And then Android SDK provides us a data access layer where we can use to access data in the local database that runs within the Android application as well as we can access data which are available remotely in server, especially when it comes to like track entity instance queries. We can instruct the SDK to query both local database and the remote database at the same time. And the last feature I would like to highlight is support for last latest DHS2 version, so you don't have to worry about manually supporting latest DHS2 features or manually changing your code to handle the complicated API calls, so latest API calls. So SDK is going to mask all of them out for you and just provide a convenient way to communicate with the remote server. So let me introduce you to the skeleton app, which we are going to use throughout this session. So the skeleton app is something that has been developed by the UI and Android team where you can use as the entry point to develop a new application from scratch. So I mean it has all the boilerplate code that is required to start with the new application development and also it has some branches that kind of shows you the features available in the SDK. So it is available on GitHub. So you could either type this URL or you can simply do a Google search for DHS2 Android skeleton app and probably it will come as the first result. So there are many, many branches in this repository and master branch is going to have all the boilerplate code that is required to start a new application development and then there are use case branches which kind of shows other capabilities of the SDK. So the first exercise that we are going to do today is cloning the repository and start the Android studio and cloning the repository and get the master branch of the application up and running on the virtual device. So I hope you already got Android studio installed and virtual device already in your machine. So I mean please, I will kind of demo how to do this but I am kind of new to follow the same. How many of you have Android studio installed already? OK, we have you. So yeah, so in order to start, let me first go through the GitHub repository. So then you can click on code and copy the HTTPS URA. And then in the Android studio you can start a new project from version control and paste the URA. For some reason it's the wrong one. So I hope it will work on your machine. So you simply have to paste the URA here and just click on the clone button and it will simply clone the entire GitHub because it tree onto your local machine and it will start a new Android project and it will probably start indexing the code and then you should be able to start the application as if you already have an Android virtual device. So I already have that step. So I will give you some minutes to go ahead and clone the repository and start building the application. If you need any help, please raise your hand so I'll be able to come and help you. So since we have a limited amount of time, so I will assume that you are following these steps and you have the Android application already clone. So if the application is properly cloned, you should be able to start the application by simply clicking on it's not clear. But there's a green run app button in the Android studio. So if you click on that button, it should build the application and start the application on the virtual device. Actually it will build the application and install that onto the virtual device and it will start application. So while it's building and starting, let me move on to the next section. So it's about the SDK instantiation. So if I introduce you to the workflow of the entire Android SDK, so the first step of using the Android SDK is going to be initializing the SDK. And then in order to use the rest of the features, you should have a user logged in properly to the application. And then there's a cycle of metadata synchronization, metadata synchronization, and then do some kind of work, maybe creating new track entities, such as events, and then uploading them back to the server. And the cycle can continue as long as the user is validly logged in. So when it comes to the initialization of SDKs, so in Android SDK, the entry point is going to be something called D2. So we have this D2 object, which probably stands for DHS2. And this acts as the entry point for all the modules and because it is in the, which are supported in the Android SDK. It is kind of the entry point for doing any operation with the remote DHS2 server, as well as with the local Android database. For creating the D2 instance, they have provided something called a D2 manager, which kind of accepts some configurations, which will be used to initialize D2. And it allows you to create a D2 instance in a synchronous manner or an asynchronous manner. So you can choose whatever you like, based on your requirement. So this is how you would use D2 configurations, sorry, D2 manager to initialize a D2 instance. So first you have to have D2 configurations initialized. So for that, you can use the D2 configuration builder and you have to pass a context object into the D2 configuration. So it will be used by the SDK to access device resources, such as file system or to create databases and all. And then you can provide an application name and application version. So these things will be useful if you want to do analytics in the server side. I mean, those analytics are not provided out of books from DHS2, you can use maybe your proxy server to analyze HTTP headers and generate a useful analytics because that name and that portion are going to be included in HTTP headers by the Android SDK with the every restful that it will be doing with the server. And then you can add some additional parameters like network timeouts and all. And then finally you can build the configuration object that can be passed into the D2 manager to create a D2 instance. And then once you have passed configurations properly, you can either create a D2 in a blocking manner or you can use an asynchronous manner where you can subscribe into the D2 creation event and then use V2 within your application. So the exercise two is going to be about initializing the SDK. And for doing that, I mean, the first step is really straightforward. I mean, the exercise one, it's just about calling the repository and starting the application which should work without an issue. So the second exercise, I mean, for the second exercise, you will have to check out this EX01 configuration branch. So if you are new to Android Studio and get support on Android Studio, you can check out new branches by, I think there's a slight delay. So you can, I mean, if you check the right hand bottom corner of the Android Studio, there you will find the branch name and you can simply click on that and search for the desired branch which is going to be EX01 configuration in our case. So I'm going to do that EX01 configuration. So you will get several branches with the same name but choose the latest one which is 2225 online. So that is the latest version of this exercise. And you can go ahead and check it out. And then you should get a Java class called sdk.java, which has some blank method where you will have to create and initialize the D2 instance. And also I want to mention that this D2 instance is the single term. So there will be only one instance of D2 for the entire lifetime of the application which is really important to avoid conflicts. So I'm going to go ahead and write that piece of board but I think there's a slight delay between my screen and the zoom. But I hope you'll be able to follow it. I mean, I think since large screen is not clear if you could join the zoom channel then it will be more clear for everyone. Some kind of a name, pass version. So that's 0.01. 1, I'm going to, I mean, you should be able to read, I mean, all the instructions, it's available as an annotation in the exercise itself. So it is asking us to use the DD configuration builder and set the context and set your username as their name and then set the version. And then set timeouts, I mean, connection timeouts, read timeouts and write timeouts as two minutes. And when setting those timeouts, these timeouts are accepted in seconds. So we will be setting 120 as the write timeout. And then finally, once you are done with all the configurations, you can simply call build which will give us back a new configuration. You can return. And there are other configurations like adding network interceptors. So if you need to intercept all the network calls to DHIS to server by the SDK you know, use some kind of debugging or analysis, then this is where you can set them as well. So the skeleton application kind of has this already. So, I mean, it is using Flipper, it's a tool by Meta. Flipper, you can set that as well, but if you don't have Flipper on your machine currently installed, then you don't have to do that. I hope everyone is following. So since this one is really the simple one, I will just move on to the next section and this session is going to be recorded. So hopefully you will be able to follow the exercises data as well. So the next section of the workflow is about logging in. And now we have initialized the SDK and it is ready to use. Before doing any operations of data or Meta data or interacting with the DHIS to server, we have to log into the application with the value DHIS to user. And the good thing with the SDK is that it supports multiple user server combinations. So you can use the same application across multiple servers and multiple users can log into the same application. So how it handles that is internally it's going to have a separate encrypted database per user server combination. So once a user logging in into the application via the SDK for the first time, obviously the SDK has to be online when it's happening for the first time. And if that login is successful, SDK is going to cache that username password combination. I mean, it's not going to keep that in plain text. It's going to create a hash and it's going to persist that into the database. And then the same user can log in for the second time by the app is offline. The SDK is going to copy out the hash of username password combination locally and it kind of allows the user to log in if there's a match. So this basically explains what I just described. And yeah, the only hard requirement is that the SDK has to be online if the user is in. So that's basically working. And in logout SDK kind of disables any interactions with the local database and the remote server for that particular user. But once you log out, it's not going to clear any databases. So it's going to preserve the database for that user and server encrypted. And it could pull up the database if there's a subsequent login from the same user. So it's not going to clear any data. But it will just part of the user from any new interactions must the user is logged out. And logging in and logging out with the SDK is super simple. So I mean, compared to what we had to do before we had the SDK. So you simply have to get the d2 object which is the entry point of the entry point for any SDK related operation. And then get the, corresponding one module. So in this case, we are doing a user operation. So we have to get the user module and then we can simply call login and pass the username, password and the URL to the server. And then it would, I mean, as long as the SDK is online it will allow you to log in. And then for logout, it's simply calling user module that logout because at a given point there can be only one active user. So it's simply calling logout, it will allow them to use out. So the third exercise is around the user authentication. So it's available in this EX-02 login branch. So I hope you will be able to check out that branch and you simply will have to fill some methods in login-beam-model class and login-activity.java class. So those are the two places where you will have to implement login and you, I mean, the logout is omitted in this exercise. You simply have to do a login and then you can show a toast message welcoming the user, maybe simply do a toast saying welcome and then use it. So I'm going to do the same thing and I hope you will be able to follow it or maybe follow the, maybe you will be able to follow the recommendation, whichever you prefer. So if you have changes in the changes from the previous branch, so since this is just for exercises, you can simply do a first checkout and it will discard all the non-popular changes and simply check out the branch that you will be able to do. So the first class that we have to modify is login-beam-model.java. And here we have an annotation explaining the exercise. So it is asking us to pull login method in your user module and it has provided us with the username, password and the server URL. So as usual, I will have to get hold of the E2 instance and then I'm going to do something regarding the users. So that means I need to use a module and there I can call login username, password, and server URL. And then the next class that I'm going to edit is login-activity.java where I will be doing a toast to the user. So this is an activity, so I can set the past this as the context and then I'm going to print the message hello user and I will just print the name and some exclamation marks and the left of the toast maybe it's going to be a long toast and then I'm going to show at the end. Now if I run the application, to start the application and give me a URL to enter this URL username and password. So this server is currently offline so we can probably use play instance. So I'm going to use the 2.37 instance here. And I will be logging in with the admin distributors. This IDD is successful, you should see this post as saying hello, John. Just following or do you need time to try it out or should I just press it? So then I'll move on to the next stage of the workflow which is about synchronization and when it comes to synchronization we have two types of data that needs to be synchronized. The first type is metadata and the second type is going to be data. So metadata synchronization is crucial before doing anything else on this instance or on the application. And before going into the more code level examples let me introduce you to the data access layer of the Android SDK. So it has two components, public and private. So public part is something where the developer can freely access, you can freely call these methods up to the repository. So we have the D2 at the top which is kind of like the entry point and then D2 exposes us to several modules and these modules can be user modules, track activity modules and event modules and so on so there are different modules. And then within those modules we have repositories which kind of encapsulates operations on these entities. And then if we call any method on these repositories then it goes to the private space where a valid user or a valid authentication is required. So it could be a database access or it could be an API access for both of these cases a valid authentication is required and it is going to be controlled by the SDK. And as I previously mentioned before you do anything with the SDK I mean anything data related with the SDK you have to have the SDK D2 instance configured and you have to have a valid user logic. So these three are the three or two steps up the kind of like the prerequisites for using the rest of the modules and because it creates the SDK. So the first thing that I would show you here is the metadata synchronization which is kind of like the third mandatory step after a login. I mean you can't do anything related to data without actually having metadata so we can consider this as the third mandatory step. So it's really simple. Imagine what you had to do before you had SDK you had each and every API endpoint metadata API endpoint to synchronize download the metadata you had to have a paging and everything and populate your database with those metadata not to mention that you even had to create the database tables and the relationship between those tables and everything you had to do kind of manually but now you seem to have to call D2.metadata module and you can do a download of metadata and it's going to take care of everything for you it's just a one line of code. And then with downloading data so mainly we have three types of data in any DHR instance or in an Android application so the crack net data and event data and aggregated data. So I mean it's simple I mean if you want to do something with the SDK it's simple to determine what methods should be called so you have to first start with the D2 and then realize what you need to do so if you want to download track entity data then obviously you have to select the track entity module so I mean that structure and intelligence by IDE combined makes it really easy for you to find the corresponding methods in the SDK without having to go through the documentation. So in this case if I want to download track entity data I will take D2 and then the track entity module and then the repository is going to be track entity instance downloaded and then it provides us some capabilities to limit the limit what we are downloading so we can limit the number of instances to 10 or maybe you can limit by program ID you can limit by organization limit ID so those kind of limits are provided by the SDK itself to provide, to avoid flooding the network and then you can see before download once you have all called all the configuration that's related to this download and same applies for events so if you want to download events you start with D2 and then we need to do something with events that means we need to get the event module and then what we need to do with events is downloading so that means we need to download the repository and then we can do the configurations like setting the limits and then finally the action module which is D2 and if you are not building an application with the SDK if we assume that you are using the REST API you will remember that with most of the data you have 10 points of DHIS2 it provides filtering and ordering so the same support is available there in the SDK so you simply have to call a combination of methods to achieve the same thing that you achieve with the REST API so for instance if you want to filter events based on the organization unit and the event date you can simply do that by again going through the same hierarchy so we are doing something with events so we need events for you and then the repository so we are going to do a read of the events so we are going to do the events repository and then we will be setting the filtering parameters so in this case I will be filtering with organization unit ID and that ID is going to be equal to some kind of an organization or UID and then I would like to filter that by event date and I want all the events that come after this particular date so it supports all the possibilities like before, after and things like that so then once you are done with configuring the repository you can simply call the action method which is in this case going to be gate previously it was downward and in this case it's going to be a gate same applies for ordering so it is also another kind of configuration that can be done on the repository so I can simply ask the SDK to order my events by event date and I can specify whether I need ascending or descending so it's really easy to use filtering and ordering with SDK I mean it's straightforward and then another important feature available on the SDK and especially the data access layer is requesting for nested fields so if you can remember how it works on the API when we call the event set point it's not automatically going to give us the data values instead we have to specify that we need the data values as well because otherwise the payload is going to be really, really huge and in this case I mean if you assume how the data is starting the Android SQLite database so there will be probably two tables unlike the HIs to database case so in order to prevent unnecessary joints we have to manually request for the nested fields so in this case if I need the data values included in the results set I will have to manually specify that I need the data values with the final results so if I can specify that by doing another configuration call which is with track identity data values so now it's going to do all these filterations and then do all this I mean do the ordering that I have requested and also it's going to join that with the data values table and fetch all the data values corresponding to the events and then build the final payload and final job objects and send them back so the next exercise is going to be about synchronizing metadata and data so it's basically implementing the same things that we just discussed and it's going to be available under exercise three sink and list branch so I'm going to go ahead and do that and hopefully we'll be able to follow and maybe later use the recording to complete the exercises and the exercise is going to be ES03 sink and list I'm going to check out and I'm going to do a post-checkout because I'm going to meet my previous changes and then I have this so the main edits are going to be on the main activity and the program's activity so if I go to the main activity I should be able to find my exercise here so the first exercise is to download metadata so for that I have to do SDK into metadata and I have to get the metadata module and simply do a demo and if I go back to just show you how these methods have been called so when the sink metadata is called I mean in the skeleton application we have these products for sink metadata, sink data and also for uploading data so once the sink metadata is called it's going to call the download metadata function that we just implemented and it's going to do that on the IO threads and once that call is done it's going to hand over the control back to the Android main thread and if there's an error in the metadata download it's simply going to print the stack trace for now and for now and if the operation is successfully completed it's going to start the program activity and show us a list of programs that were synchronized by the operation that we just did so similarly I should be able to go ahead and implement the tracked entity instant synchronizations so I need the tracked entity module and I can't go to download the tracked entity instances so that's the repository I need and I can see the code, the download function and same applies for the events SDK, need to, I need to give it and I need the human downloader and this is the code and also you should be able to add limits here as I mentioned, so you have multiple options you can limit, you can simply add a global limit or you can limit by organization unit or limit by program so if it is a global unit it's going to just download track I mean if you set the limit to 10 it's going to download 10 tracked entity instances but if you limit by organization unit it's going to download 10 tracked entity instances from each organization you need to access it with this user so for this exercise I'm going to set a limit of 10 as instructed and I will be doing the same for the human sensor and then I have to do the aggregated data and for aggregated data there's no such thing for the limits because it's kind of like I mean we can't define a limit for the aggregated data so I can simply get the data because it's free and simply download the aggregated data for me and now if I run the application it should build the application and start it so in this application I have when in the run configuration I have set this flag to clear up storage before deployment since we are doing multiple different examples it's easy to let it clear all the data when we are deploying the application otherwise we will have to manually go and clear the application data if we encounter any errors so I'm going to log in again to the play instance when the log in is successful I can simply click on sync metadata and it's going to take few seconds to synchronize metadata depends on the speed of your mentor so it's allowed to synchronization and once synchronization is done it should I mean based on what we have instructed here it's going to start the or open the program activity so now it has opened the program activity and the second component of this exercise is to implement or complete the program activity so that it will read programs from the metadata that we just synchronized and display them on a list but I will simply skip that step for now because it's really really straightforward you just have to take the program module and then you know just for it so let me introduce you to the data states which are being used to be Android SDK so this is something related to that I first described about handling everything manually so if you want to handle everything actually we kind of have to manually manage all these states within the database but at the moment SDK is doing everything for us so there are several states that are being used by the SDK to properly handle the synchronization between the local application and the remote server and the first one is sync so which stands for I mean which indicates that all the elements related to a record has been already synchronized and there are no local changes for that value for instance if it is a track identity maybe a track identity attribute then when you newly created it it won't have the sync flag it will have something like two post flag because it should be it is yet to be synchronized with the server and once all the data data related to that particular entry is synchronized properly back to the server and if the server acknowledges that the synchronization is successful then it's going to change the state back to the sync and the next state is two post which is added for the newly created entries which kind of indicate that this data is only available locally and this should be synchronized with the server and the next state is two update which is the state that will be used for the already synchronized objects but once the synchronization is done there has been some kind of an edit happened on that object so it can be like if there is a track identity attribute or name if it is already synchronized and if a user changed that name to something else this will be the state that will be used to indicate that change so this is kind of like the workflow of changing states within the database so if we create something new it will be two post the state will be two post and then when we click on the upload data it will simply go ahead and change the state to uploading which indicates that upload is still ongoing and if the upload is successful it will go to the sync state and while the upload is going on I mean it is also allowed to edit that record I mean it is imagine how hard it would be to implement this on our own so if I mean if there is an edit while the upload is going on the state is going to add the flag to update to that record and even if the previous upload is successful it's not going to change that flag back to sync because there are new updates on the on our object and then we have two other states to handle errors and warnings which are kind of like set up and these are the two most important states that I would like to show you today that's sync via SNS and sync via SNS previously when we were developing Android applications we kind of had only one option for synchronizing data from Android application to the server so what happened at the community level was the users kind of collect data within delay and then they come back to the come back to their office where they have internet connections and then only they could synchronize data into the servers so especially that was what we have been doing with the DNS application in Sri Lanka but now with the SDK we have the support for synchronizing data via SNS so SDK kind of use some compression libraries to compass data and efficiently transfer them into the server via SNS and also it relies on responses back from the server which indicates the success or failure of reporting those data and there are some cases when the SNS gateways are not configured or if there is no SNS gateway at all there are some cases where the server does not send any response so in that cases the SDK will simply have sent via SNS state and if there is a response from the server if the response is if it is successful it will simply add sync via SNS which is kind of the best state that we could have and synchronizing via SNS alright so the next one is about Tractive Fist Search I mean there are other search options as well like Tractive Fist Search and all but Tractive Entity Search is kind of special because it supports multiple modes like I mean it supports four modes so the first mode available is Hop-Flight Only so in this case if you do a Tractive Entity Instance Search it is going to search only the locally available Android Database and so yeah it will only include the locally available Tractive Entity Instances and then we have the next option Offline First and if we specify that and if the device is online the SDK is going to first search the local database and get all the TEIs available and then do an online search and then do some kind of duplicate handling to eliminate duplicates that get from both local and online and it is going to append that online result to the bottom of the offline results that present to the user and then we have online only search we will simply ignore the locally stored data so if the user has some non-synchronized Tractive Entity Instances on the device this search will not include them it will only include Tractive Entity Instances from the remote server and then same as offline first we have online first where it will include all the TEIs from the remote server first and then it will put in the local database and handle the duplicates and append that result back to the result from the online database and present that to the user so this is kind of like how that happens so I mean so if we kind of have request for ordering it's going to order within these some groups so this is kind of like showing the offline first mode so it's going to take offline data from the local database so DEI 1, 2, 3 are going to be from local database and then it's going to request from the remote server and DEI 4, 5 are going to be from that server and they are going to be in two different they are going to be in same they are going to be arranged in this menu so the so the example syntax for querying Tractive Entity Instances is I mean it would look something like this so it's same as before we need to do something with the Tractive Entity Instances so we start with D2 and we do the TractatedInModule to do a query so I mean with intelligence you shouldn't simply I mean from here you can simply search for query and it should probably suggest the method that needs to be called and then you can add all the configurations I mean if you want to filter by organization units or if you want to set some kind of an opening mode and also if you want to search for a program so those kind of configurations can be added here and then that is about filtering and then we can do ordering so you can order by attributes order by enrollment date and you can specify one of the four modes that I just described and then also you can add some pages if it is necessary and then it should you know do the magic pose so the exercise for is an exercise that is about coding TractatedInstances based on the syntax that I just showed let me see even though we have time so with D2 and now, we started half an hour late so it kind of depends on sharing or if you want to take a bit of a break yeah so yeah I have one more section to cover so I will probably skip this exercise because it was optional anyway and the last last part of the session is about data creation so data creation is required if you want to you know support a screen like this where you have a data interface and you want to create TractatedInstances and TractatedInstances attributes so okay it's when you are using SDK you really don't have to follow any documentation you simply have to rely on intelligence so we start with D2 and we can get the TractatedInstances module and then we want to create a TractatedInstance and that is the repository we need and in that repository we can simply call and add where you can use TractatedInstance create projection to you know set the configurations and then you can simply add that to the local database so it's not going to add into the remote database yet so it will first add that to the local database and when you do that it will upload stuff to the database so the next exercise is about about that actually TractatedInstances so if you have if you have time I can go ahead and follow maybe if I'm wrapped up in the next 15 yeah so if you want to follow with me so the exercise is going to be on EX-09 Tracker Data creation and go ahead check out that branch so the exercise is about so it says in the sign menu you can go to the programs and you can select the program and click on the last button we should be able to create a new TractatedInstance so if we run the application we can go to the changes just to show you how it works it works up to the point where we want to create TractatedInstance also I mean when you're trying these exercises offline if you want to use your own instance you should be able to change these hard coded values here in the section so search for photofill URL photofill username and photofill password sorry and you should be able to change these values so every time you run the application it will automatically fill those values for you so in my case it's going to be in the description and I will rerun the application so it has filled the form with the design of the metadata synchronization first design the programs if I want to add a TractatedInstance I may throw it that TractatedInstance into the program and while it's loading let me go ahead with the exercise the first part of the exercise is about creating the actual TractatedInstance so it's going to be TractatedInstanceActivity the synchronization is done so we have all the programs loaded so if I click on the child program and if I click on plus it's not doing anything because we haven't done the implementation so that's what we are going to do now so I have TractatedInstanceActivity so I'm going to do that exercise TractatedInstanceActivity so it says set any organization you need to capture scope set the TractatedIn type associated to the program this is what I'm going to do I'm going to take the ET TractatedInstanceActivity from the model I want to get the TractatedInstance repository and set the coordinate you can rely on intelligence to you know the rest of the recording and then I have the TractatedInstanceCreation TradeProjectionBuilder and I have set the TractatedInstanceActivity type here and then the organization unit then I'm done with the exercise9 behavior I have created the TractatedInstance and I have said that the local database when I'm done with these four lines of data and the exercise9 me is controlling this TractatedInstance into a program so it is available under the enrollment form activity so I'm going to go to the exercise me so it's the enrollment form service to create an enrollment so I can rely on the intelligence so this is what I need to do I need to create an enrollment form projection and set organization unit I mean I have to configure the enrollment with all the required parameters and TractatedInstance is going to be DEI UID and these are the these are the mandatory parameters for creating an enrollment so once it is done I mean the enrollment repository is going to point at that newly created enrollment so I can go ahead and set the enrollment date at incident date to the new enrollment that's done, exercise9 me and then exercise9 will be it's about attract entity attribute values so the exercise won't ask to save the value if not empty otherwise clear attribute value and delete the existing value just end so I mean I will first handle the empty case so I can simply use e70 utility function from the android native speaking and I'm going to check whether the value is empty if the value is empty I can hold delete definitely because I have already loaded the value I mean I have the code for the exercise has already loaded the corresponding attract entity attribute value so now the repository points at that value and if the value exists I can simply instruct the sdk to delete that value and if it is not I should be able to set maybe do a blocking set to update the value and I'm going to just do a print status if there's an exception so all the blocking calls I mean we should expect an exception with all the blocking calls yeah so that's all I have to do here so now I can simply apply my code changes without having to reload the application so there's an option or apply for changes in the android studio so if I click on that it's going to build the program and then changes now if I click on the plus button it's going to show me the environment form where I can set the last name first name and gender and save the attract entity instance as a bonus step in the in this exercise we have an automatically generated ID for this attract entity instance so let me show you how easily we can generate you know such unique IDs for for any kind of attract entity entity so that is available under environment form service as the exercise 090 so all the coding has been done for us we simply have to generate the value here so I want to do a I mean I want to use the reserve value so how this generation happens is it's going to you know with the devices offline it's going to request the remote instance for some values generated for this device let's say it generates 100 values for us and then when the device is offline it's going to use those values so that's how it was otherwise there's no way for avoiding the collisions so since this is a attract entity attribute I am going to use attract entity module and so I want to use the reserve value and I will do a blocking gate for that reserve value and I have to pass the attribute ID so that I can get from writing and also I need to pass the organization because these values are relative to the organization so for that one I am going to get the current enrollment and do a blocking gate and simply give the organization and that's all now if I read out the code click on plus plus button so it's going to give us a reserve value I mean we are going to use one of the reserve value and now we can simply fill in the form and click on save so this is something that I created so this is for the previously created one so it's anyway going to be an attract entity but once the enrollment form is paid or it's going to be an enrollment attribute so this is the one that we are going to just create so that's all I have for this session and some people have to go really really fast and not being able to allow you sometime to try the exercises and before I start conclude I want to especially thank Grecia and the way you are ready for providing us with this material and exercises and just to follow up on that as well if anyone's got any questions what's the best way to get in touch with you yeah you can send me a message cool sweet thanks we'll take a break now for 20 minutes and come back for the final session at half past