Hey there.
Well let's start implementing the database for that application.
Well let's move to our project and as you remember in the course the big project I created a separate
package.
I created these packages in a gel package but also we can put this packages in the package go by Liverpool's
let's get started here we create the package and call it data
later in this package we will create a class I want to structure this project a little differently.
I want to show you a structure that can be used if there are several tables in your database in our
database club Olympus.
There will also be one table but I will show you how to structure if multiple tables let's create a
jello closet here and I will call it Club Olympus contract
then name can be anything but the name contact is common for classes used by Android to store data in
a database about various constants.
Create this class and we declare it final scenes since we will store various information here not a
base version database names tables names column names of our tables.
That is it is an information or a class as specified and final we indicate that we cannot inherit from
this class since we do not need this.
This is purely helper class which is used as some kind of container so that you can easily access information
in one place and next.
Inside this class we can create several inner costs for each of the tables.
If we have several tables we'll have several in the classes.
First let's create a private constructor so that we cannot create an object of this class.
Since I already said we do not need this we will be accessing through static fields create in this private
constructor.
We make it so that no one can create an object or this class outside this class and then inside.
We are already creating public static final class right.
Name of the class member entry.
I will name it that is it will contain information about the club members table.
So first let's specify that public static final String constant.
And call it table name which accordingly will store the name of all table said the value members next.
Call it create the common sense for our columns.
First name last name gender and group for columns an idea total of five will be one two three four five.
The names we of course change K D.
Key name
keep first name.
More precisely
kill last name
key agenda
and key group
respectively here will also change the values of the column names here.
First name
last name
gender
and group.
That is when we create the table.
We will use now the value with these values but by name over the constants I already told you.
This allows you to avoid errors in the code in the future.
When we turn to these columns somewhere we can make some kind of type in some.
But when we call by name or the constant we know for sure that we use the same name everywhere here
and in the subsequent code the names or the constants may not necessarily be the same as we specified
in cause.
Maybe we can't call them different too.
For example call I.D. like these Mister instead of key first name.
Let's do this so that you understand that it's not necessary.
Key specified here I can specify column first name that is here everywhere I can insert instead key
column and everything will be the same.
We'll just use different names and also in our class add member activity.
We use the numbers that we assign to all of the variable gender of an integer type and we have only
three numbers here.
They also belong to our database so we can also make constants for them and then to access to constants
but not to the numbers.
Let's do it it's considered a good style to create constants in such cases.
So let's create this public static final int only care will be gender
known.
First gender
we assign 8 0 value and 2 more constants gender male
one value engine a female assigned to
and now here we can refer to Constance and that is we specify the name of our class club Olympus contract
dot net.
Next the name of the in class member entry.
Huh.
I named it with a Smollett and this is for all.
Let's write it with the capital.
It is customary to ride glossies so with a capital letter here to member entry and gender unknown
it will be like this.
We refer to this constant then again clop Olympus contract the same man.
But entry and gender male
are a mere stopped every day.
So on the contrary here is male.
Right.
And here is female and here unknown.
Yes yes.
Male female.
No no.
Correct
in this way.
So that the name here is not so long.
We can specify in the import where the class club Olympus contract is being imported.
We can specify.
Not a whole class but only its internal class member.
Entry.
That is we can like these here.
Set and delete these import.
So it is imported automatically let's first remove these callable Olympus construct so that they import
is not automatically added to me
and now this import.
We can delete it.
We don't need it just like they are really since we do not use this implementation.
And now the name they are more exact the reference to constants.
It looks like this.
We can also use another constant in our contract instead of a D.
We can use the I.D. which is located in the interface based columns took on Ceasar defiant in this interface.
It contains all the two constants call and count and idea if we click on the constant side D then we
can see its value.
Its value is shown using the string on the score an idea.
And here are the classes that implement this interface.
Here you're going to find a lot of them were written at the end and 99 other classes.
That is a class that uses an enumeration of some records that use an idea and the number of these records
count including our table.
Can you use this interface.
Let's implement this interface in our class member activity.
Right implements base columns
and now here we can specify the value the constant specify the constant and send the value constant
of this interface.
In this way we created a class member entry for 1 table.
If we have several more tables we can create some more internal.
Public static final classes that is this record's structure is very convenient as it contains in one
place.
Information about all the database tables and so we created the structure of the members table and in
the next we do.
We will continue to develop that database.