From: Damyan Ivanov Date: Sun, 2 Dec 2018 10:54:34 +0000 (+0000) Subject: helper class for DB stuff X-Git-Tag: v0.3~362 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=65e1c4a034f5f08db9117f7211ca924e2e293f8e;p=mobile-ledger.git helper class for DB stuff --- diff --git a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java b/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java new file mode 100644 index 00000000..2aee5331 --- /dev/null +++ b/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java @@ -0,0 +1,24 @@ +package net.ktnx.mobileledger; + +import android.database.sqlite.SQLiteDatabase; + +class MobileLedgerDB { + static final String DATABASE_NAME = "accounts"; + private static String db_filename; + static SQLiteDatabase db; + + public static String getDb_filename() { + return db_filename; + } + + public static void setDb_filename(String db_filename) { + MobileLedgerDB.db_filename = db_filename; + } + + public static void initDB() { + 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);"); + } +}