kittyger.blogg.se

Sqlitedatabase
Sqlitedatabase










sqlitedatabase

In order to implement this interaction in a structured way, a third class will need to be implemented to hold the database entry data as it is passed between the activity and the handler. The database handler will be a subclass of SQLiteOpenHelper and will provide an abstract layer between the underlying SQLite database and the activity class, with the activity calling on the database handler to interact with the database (adding, removing and querying database entries). Once completed, the application will consist of an activity and a database handler class. The database schema for the products table is outlined in Table 34-1: Column Data Type productid Integer / Primary Key/ Auto Increment productname Text productquantity Integer The productid column will act as the primary key and will be automatically assigned and incremented by the database management system. Each record in the database table will contain a unique product ID, a product description and the quantity of that product item currently in stock, corresponding to column names of “productid”, “productname” and “productquantity” respectively. The name of the database will be productID.db which, in turn, will contain a single table named products. The idea behind this application is to allow the tracking of product inventory. As is probably evident from the user interface layout designed in the preceding chapter, the example project is a simple data entry and retrieval application designed to allow the user to add, query and delete database entries.












Sqlitedatabase