-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoggingRecordDBHelper.java
100 lines (88 loc) · 3.86 KB
/
LoggingRecordDBHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.torointl.wasabi.testproject;
import android.content.Context;
import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteOpenHelper;
/**
* @author Nelson MELINA <[email protected]> Created on 17/11/2014.
*/
public final class LoggingRecordDBHelper extends SQLiteOpenHelper {
/**
* If you change the database schema, you must increment the database version.
*/
public static final int DATABASE_VERSION = 1;
/**
* name of the database
*/
public static final String DATABASE_NAME = "logback.db";
/**
* SQL string to create the table.
*/
private static final String SQL_CREATE_ENTRIES_LOGGING_EVENT = "CREATE TABLE "+
LogbackDBContract.LoggingEventEntry.TABLE_NAME + "( "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_EVENT_ID
+ " INTEGER PRIMARY KEY, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_TIMESTAMP
+ " INTEGER, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_FORMATTED_MESSAGE
+ " TEXT, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_LOGGER_NAME
+ " TEXT, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_LEVEL_STRING
+ " TEXT, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_THREAD_NAME
+ " TEXT, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_REFERENCE_FLAG
+ " INTEGER, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_CALLER_FILENAME
+ " TEXT, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_CALLER_CLASS
+ " TEXT, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_CALLER_METHOD
+ " TEXT, "
+ LogbackDBContract.LoggingEventEntry.COLUMN_NAME_CALLER_LINE
+ " TEXT"
+ ")";
/**
* SQL string to create the table.
*/
private static final String SQL_CREATE_ENTRIES_LOGGING_EVENT_EXCEPTION = "CREATE TABLE "+
LogbackDBContract.LoggingEventExceptionEntry.TABLE_NAME + "( "
+ LogbackDBContract.LoggingEventExceptionEntry.COLUMN_NAME_EVENT_ID
+ " INTEGER PRIMARY KEY, "
+ LogbackDBContract.LoggingEventExceptionEntry.COLUMN_NAME_I
+ " INTEGER, "
+ LogbackDBContract.LoggingEventExceptionEntry.COLUMN_NAME_TRACE_LINE
+ " TEXT"
+ ")";
/**
* SQL string to create the table.
*/
private static final String SQL_CREATE_ENTRIES_LOGGING_EVENT_PROPERTY = "CREATE TABLE "+
LogbackDBContract.LoggingEventPropertyEntry.TABLE_NAME + "( "
+ LogbackDBContract.LoggingEventPropertyEntry.COLUMN_NAME_EVENT_ID
+ " INTEGER PRIMARY KEY, "
+ LogbackDBContract.LoggingEventPropertyEntry.COLUMN_NAME_MAPPED_KEY
+ " TEXT, "
+ LogbackDBContract.LoggingEventPropertyEntry.COLUMN_NAME_MAPPED_VALUE
+ " TEXT"
+ ")";
/**
*
* @param context to use to open or create the database
* @param cursorFactory to use for creating cursor objects, or null for the default
*/
public LoggingRecordDBHelper(final Context context, final SQLiteDatabase.CursorFactory
cursorFactory) {
super(context, DATABASE_NAME, cursorFactory, DATABASE_VERSION);
}
@Override
public void onCreate(final SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL(SQL_CREATE_ENTRIES_LOGGING_EVENT);
sqLiteDatabase.execSQL(SQL_CREATE_ENTRIES_LOGGING_EVENT_EXCEPTION);
sqLiteDatabase.execSQL(SQL_CREATE_ENTRIES_LOGGING_EVENT_PROPERTY);
}
@Override
public void onUpgrade(final SQLiteDatabase sqLiteDatabase, final int i, final int i2) {
// TODO implement process to upgrade the database to a new schema when it's modified;
}
}