DBXDroid
DBXDroid copied to clipboard
Simple ORM Library for Android SQLite Database
DBXDroid
Index
- Description
- Features
- Compatibility
- Installation
- Use
- License
Description
This is android library to simplify Android SQlite Database
Refer DBXDroidDemo for Usage.
It become very tedious to write large Android SQLite Open helper for simple database usage. So I developed this library to create android databases very easily using straight forward functions.
Features
- Create Android SQLite Database
- Add Tables to database
- Insert new entry to tables
- Fetch entries from tables
- Ability to interact with database directly using getDatabase() function.
Compatibility
DBXDroid library is compatible for Android 2.3+
Installation
To use DBXDroid ,
- Download Library
- Extract it to DBXDroid directory
- Copy it to your Android Project Workspace
- Add it as a project to your Android ADT
- Edit properties of your project -> Android -> Library -> Add DBXDroid as Library
- Library is now ready to use
Use
1. Define Database
DBXDatabase studentDatabase;
studentDatabase = new DBXDatabase("college.db", this);
2. Create ColumnList
DBXColumnList studentColumns = new DBXColumnList();
studentColumns.addColumn(new DBXColumn("student_id",DBXFieldType.INTEGER));
studentColumns.addColumn(new DBXColumn("student_name",DBXFieldType.TEXT));
studentColumns.addColumn(new DBXColumn("student_dept",DBXFieldType.VARCHAR));
3. Add new Table to Database
studentDatabase.addTable(new DBXTable("students", studentColumns));
4. Create Database
try {
studentDatabase.createDatabase();
} catch (Exception e) {
e.printStackTrace();
}
5. Open Database
try {
studentDatabase.openDatabase();
} catch (Exception e) {
e.printStackTrace();
}
6. Inserting new Entry to table
DBXFieldValuePairList studentFieldsList = new DBXFieldValuePairList();
studentFieldsList.addFieldValuePair(new DBXFieldValuePair("student_id", Integer.parseInt(studentID)));
studentFieldsList.addFieldValuePair(new DBXFieldValuePair("student_name", studentName));
studentFieldsList.addFieldValuePair(new DBXFieldValuePair("student_dept", studentDept));
try {
if (studentDatabase.insertEntry("students", studentFieldsList) != -1) {
Toast.makeText(this, "Added", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
7. Fetching Entries
DBXResult dbxResult = studentDatabase.getEntries("students");
String[][] result = dbxResult.getResults();
8. Access Database Directly
public SQLiteDatabase getDatabase();
This method returns SQLiteDatabase object reference for your database, So you can interact normally and directly to database
9. Closing Database
try {
studentDatabase.closeDatabase();
} catch (Exception e) {
e.printStackTrace();
}
Refer DBXDroidDemo for Full Demo
License
DBXDroid is under the GNU General Public License v3.0 License.