else {
MobileLedgerDB.setDb_filename(MobileLedgerDB.DATABASE_NAME);
}
- MobileLedgerDB.initDB();
-
- MobileLedgerDB.applyRevisions(getResources(), getPackageName());
+ MobileLedgerDB.initDB(getResources(), getPackageName());
account_list_last_updated = MobileLedgerDB.get_option_value("last_refresh", (long) 0);
MobileLedgerDB.db_filename = db_filename;
}
- static void initDB() {
+ static void initDB(Resources rm, String pkg_name) {
db = SQLiteDatabase.openOrCreateDatabase(db_filename, null);
-
- db.execSQL("create table if not exists accounts(name varchar);");
- db.execSQL("create index if not exists idx_accounts_name on accounts(name);");
- db.execSQL("create table if not exists options(name varchar, value varchar);");
- db.execSQL("create unique index if not exists idx_options_name on options(name);");
- db.execSQL("create table if not exists account_values(account varchar not null, currency varchar not null, value decimal(18,2) not null);");
- db.execSQL("create index if not exists idx_account_values_account on account_values(account);");
- db.execSQL("create unique index if not exists un_account_values on account_values(account,currency);");
- }
-
- static void applyRevisions(Resources rm, String pkg_name) {
- int cur_ver = Integer.parseInt(get_option_value(OPT_DB_REVISION, "0"));
+ int cur_ver = Integer.parseInt(get_option_value(OPT_DB_REVISION, "-1"));
Log.d("db", "Current DB revision is "+String.valueOf(cur_ver));
--- /dev/null
+create table if not exists accounts(name varchar);
+create index if not exists idx_accounts_name on accounts(name);
+create table if not exists options(name varchar, value varchar);
+create unique index if not exists idx_options_name on options(name);
+create table if not exists account_values(account varchar not null, currency varchar not null, value decimal(18,2) not null);
+create index if not exists idx_account_values_account on account_values(account);
+create unique index if not exists un_account_values on account_values(account,currency);