This app will be using SQLite database and MVC paradigm, so make sure you have understood them.
Firstly, we need to make an Android project first (Learn to create Android project with Android Studio).
Name your package to any name you like, but for this tutorial I name the package to be id.aft.appinventory. You can change it to the name you like.
As I mentioned in the second paragraph above that this app will be using MVC paradigm, and we will use mode class, which is item.java.
The item class takes the role to define item object along with its functions and attributes. Just like item in general, they have names, ID, brands and etc.
So the following are the codes.
We have the item inventory model now. Simple isn't it? However the above class only contains attributes and functionalities getter and setter.
So after we have finished creating the item class, now we continue to create Helper Database class.
As its name refers to, this function is to facilitate us for creating and accessing SQLite database that will be used by the app.
Mostly this class contains methods relate to database management, like onUpgrade() and onCrate().
Actually Database Helper has already own class, which is SQLiteOpenHelper. So we just need to extend this class from SQLiteOpenHelper class.
So the following is the code for DBHelper.java.
As we have seen above. DBHelper.java class mostly filled with constanta such as table name, database name, column name and etc.
This will facilitate us when we wish to use that constanta, we don't need to write the table name repetitively, but simply access the DBHelper class.
And there is also constanta in the form: SQL statement, this constanta by database expert is simply a command to be used for creating new database table.
SQL command will be executed on onCreate() method.