-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathsqliteopenhelpercallbacks.ftl
More file actions
48 lines (39 loc) · 1.72 KB
/
sqliteopenhelpercallbacks.ftl
File metadata and controls
48 lines (39 loc) · 1.72 KB
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
<#if header??>
${header}
</#if>
package ${config.providerJavaPackage};
import android.content.Context;
<#if config.useEncryptedDatabase>
import net.sqlcipher.database.SQLiteDatabase;
<#else>
import android.database.sqlite.SQLiteDatabase;
</#if>
import android.util.Log;
import ${config.projectPackageId}.BuildConfig;
/**
* Implement your custom database creation or upgrade code here.
*
* This file will not be overwritten if you re-run the content provider generator.
*/
public class ${config.sqliteOpenHelperCallbacksClassName} {
private static final String TAG = ${config.sqliteOpenHelperCallbacksClassName}.class.getSimpleName();
public void onOpen(final Context context, final SQLiteDatabase db) {
if (BuildConfig.DEBUG) Log.d(TAG, "onOpen");
// Insert your db open code here.
}
public void onPreCreate(final Context context, final SQLiteDatabase db) {
if (BuildConfig.DEBUG) Log.d(TAG, "onPreCreate");
// Insert your db creation code here. This is called before your tables are created.
}
public void onPostCreate(final Context context, final SQLiteDatabase db) {
if (BuildConfig.DEBUG) Log.d(TAG, "onPostCreate");
// Insert your db creation code here. This is called after your tables are created.
}
public void onUpgrade(final Context context, final SQLiteDatabase db, final int oldVersion, final int newVersion) {
if (BuildConfig.DEBUG) Log.d(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion);
// Insert your upgrading code here.
<#if config.optString("sqliteUpgradeHelperClassName")?has_content>
new ${config.sqliteUpgradeHelperClassName}().onUpgrade(db, oldVersion, newVersion);
</#if>
}
}