Content Provider – Part 1 – Contract class

Content Provider – Part 1 – Contract class

A Content Provider(CP) is a component that encapsulates data, expose them through a standard API and optionally make these data available to other applications. CP is independent of a data storage, which can be local, remote or mixed. Contract class We need a CP contract class to describe the data exposed from the CP(tables, columns, SQL creation strings, etc). The table information is in nested classes, a separate class for each table. Those classes should describe how to access the table, the table’s URI and the column name. The table…

Content Provider – Part 1 – Contract class Read More

Android – Create a DB contract class

Android – Create a DB contract class

A Database contract class is a class that holds information about the database, schema/structure. It also has constants that describes the database, tables, columns and table creation strings. One more thing to remember is that we do not need instantiate it, because it holds only information. Let’s start. Create a new Java class file. The class must be final. The constructor should be private and empty. Now create a public, static and final class for each table in the database that implements Basecolums if you want to use an ID…

Android – Create a DB contract class Read More