ORADBManager Class Referenceabstract

Inherits SQLiteOpenHelper.

Public Member Functions

  ORADBManager (@Nullable Context context, @Nullable String databaseName, int databaseVersion)
  ORADBManager (@Nullable Context context, @Nullable String databaseName, CursorFactory factory, int databaseVersion)
void  onCreate (SQLiteDatabase db)
void  onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion)
abstract void  onCreateDB (SQLiteDatabase database)
abstract void  onUpgradeDB (SQLiteDatabase database, int oldVersion, int newVersion)
synchronized boolean  insertOrReplace (String tableName, ContentValues contentValues)
synchronized List< ContentValues >  getData (String tableName, int count)
synchronized List< ContentValues >  getData (String query)
synchronized List< ContentValues >  getData (String tableName, String whereColumn, String whereArg)
synchronized List< ContentValues >  getData (String tableName, String colName, String[] range)
synchronized boolean  isTableEmpty (String tableName)
synchronized boolean  deleteData (String tableName, String colName, String value)
synchronized boolean  deleteData (String tableName, String colName, String[] values)
synchronized boolean  deleteData (String tableName)
synchronized boolean  deleteDataByQuery (@NonNull String sqlQuery)
synchronized boolean  updateDataByQuery (@NonNull String sqlQuery)

Detailed Description

Central class to manage database operations.

Constructor & Destructor Documentation

◆ ORADBManager() [1/2]

ORADBManager ( @Nullable Context  context,
@Nullable String  databaseName,
int  databaseVersion 
)

Create a helper object to create, and/or manage a database.

Parameters
context Associated content from the application. This is needed to locate the database.
databaseName Name of the database we are opening.
databaseVersion Version of the database we are opening. This causes onUpgrade(SQLiteDatabase, int, int) to be called if the stored database is a different version.

◆ ORADBManager() [2/2]

ORADBManager ( @Nullable Context  context,
@Nullable String  databaseName,
CursorFactory  factory,
int  databaseVersion 
)

Create a helper object to create, and/or manage a database.

Parameters
context Associated content from the application. This is needed to locate the database.
databaseName Name of the database we are opening.
factory Cursor factory or null if none.
databaseVersion Version of the database we are opening. This causes onUpgrade(SQLiteDatabase, int, int) to be called if the stored database is a different version.

Member Function Documentation

◆ deleteData() [1/3]

synchronized boolean deleteData ( String  tableName,
String  colName,
String  value 
)

Convenience method for deleting rows in the table.

Parameters
tableName name of the table
colName name of column to be applied for where clause.
value value to be applied for where clause
Returns
true if at least one row is deleted, false otherwise.

◆ deleteData() [2/3]

synchronized boolean deleteData ( String  tableName,
String  colName,
String []  values 
)

Convenience method for deleting rows in the table.

Parameters
tableName name of table.
colName name of column to be applied for where clause.
values values array to be applied for where clause. array can contain n number of values. All the rows matching withe values in array will be deleted.
Returns
true if at least one row is deleted, false otherwise.

◆ deleteData() [3/3]

synchronized boolean deleteData ( String tableName )

Deletes all the rows in a table.

Parameters
tableName name of table.
Returns
true if at least one row is deleted, false otherwise.

◆ deleteDataByQuery()

synchronized boolean deleteDataByQuery ( @NonNull String sqlQuery )

Delete the data in any table by passing raw sql query.

Parameters
sqlQuery valid sql query.
Returns
true if at least one row is deleted, false otherwise.

◆ getData() [1/4]

synchronized List<ContentValues> getData ( String  tableName,
int  count 
)

Get table data based on tableName

Parameters
tableName The name of table.
count number of rows to return. Return all if 0.
Returns
list of table data

◆ getData() [2/4]

synchronized List<ContentValues> getData ( String query )

Get the table data using sql query.

Parameters
query a valid sql query.
Returns
list of table data

◆ getData() [3/4]

synchronized List<ContentValues> getData ( String  tableName,
String  whereColumn,
String  whereArg 
)

Get table data.

Parameters
tableName name of table.
whereColumn name of column to be applied for where clause.
whereArg value to be applied for where clause.
Returns
list of table data

◆ getData() [4/4]

synchronized List<ContentValues> getData ( String  tableName,
String  colName,
String []  range 
)

Get the table data in between the range.

Parameters
tableName name of the table
colName name of the column.
range array of range. This array should contain two int values. Search will return rows between these two values.
Returns
list of table data.

◆ insertOrReplace()

synchronized boolean insertOrReplace ( String  tableName,
ContentValues  contentValues 
)

Inserts the data into table.

Parameters
tableName The name of the table
contentValues data to inserted in the form of key-value pair
Returns
true if the operation is success, false otherwise.

◆ isTableEmpty()

synchronized boolean isTableEmpty ( String tablename )

Checks whether table contains any rows are not.

Parameters
tableName name of table
Returns
true if table contains at least one

◆ onCreate()

void onCreate ( SQLiteDatabase db )

Satisfies the SQLiteOpenHelper#onCreate(SQLiteDatabase) interface method.

◆ onCreateDB()

abstract void onCreateDB ( SQLiteDatabase  database )
abstract

What to do when your database needs to be created. Usually this entails creating the tables and loading any initial data.

Parameters
database Database being created.

◆ onUpgrade()

void onUpgrade ( SQLiteDatabase  db,
int  oldVersion,
int  newVersion 
)

◆ onUpgradeDB()

abstract void onUpgradeDB ( SQLiteDatabase  database,
int  oldVersion,
int  newVersion 
)
abstract

What to do when your database needs to be updated. This could mean careful migration of old data to new data. Maybe adding or deleting database columns, etc..

Parameters
database Database being upgraded.
oldVersion The version of the current database so we can know what to do to the database.
newVersion The version that we are upgrading the database to.

◆ updateDataByQuery()

synchronized boolean updateDataByQuery ( @NonNull String sqlQuery )

Update the table data in any table by passing raw sql query.

Parameters
sqlQuery valid sql query.
Re turns
true if at least one row is updated, false otherwise.
 
The documentation for this class was generated from the following file:
  • ORADBManager.java