-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started to implement the database helper class
- Loading branch information
1 parent
0daa4a2
commit 5f3a2b2
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/src/main/java/de/mobcomp/grades/database/DBHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.mobcomp.grades.database; | ||
|
||
import android.content.ContentResolver; | ||
import android.content.Context; | ||
import android.net.Uri; | ||
|
||
/** | ||
* Helper class to access the database with convenience methods. | ||
*/ | ||
public class DBHelper { | ||
private Context context; | ||
private ContentResolver contentResolver; | ||
|
||
private static final Uri UNIVERSITY_URI; | ||
private static final Uri RULE_URI; | ||
private static final Uri ACTION_URI; | ||
private static final Uri ACTION_PARAM_URI; | ||
private static final Uri TRANSFORMER_URI; | ||
private static final Uri GRADE_ENTRY_URI; | ||
private static final Uri OVERVIEW_URI; | ||
|
||
static { | ||
Uri contentUri = GradesProvider.CONTENT_URI; | ||
|
||
UNIVERSITY_URI = contentUri.buildUpon().appendPath(Database.University.TABLE).build(); | ||
RULE_URI = contentUri.buildUpon().appendPath(Database.Rule.TABLE).build(); | ||
ACTION_URI = contentUri.buildUpon().appendPath(Database.Action.TABLE).build(); | ||
ACTION_PARAM_URI = contentUri.buildUpon().appendPath(Database.ActionParam.TABLE).build(); | ||
TRANSFORMER_URI = contentUri.buildUpon().appendPath(Database.Transformer.TABLE).build(); | ||
GRADE_ENTRY_URI = contentUri.buildUpon().appendPath(Database.GradeEntry.TABLE).build(); | ||
OVERVIEW_URI = contentUri.buildUpon().appendPath(Database.Overview.TABLE).build(); | ||
} | ||
|
||
public DBHelper(Context context) { | ||
this.context = context.getApplicationContext(); | ||
this.contentResolver = this.context.getContentResolver(); | ||
} | ||
|
||
// TODO: implement convenience methods for database queries, inserts, etc... | ||
} |