]> git.ktnx.net Git - mobile-ledger.git/commitdiff
helper class for DB stuff
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 2 Dec 2018 10:54:34 +0000 (10:54 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 2 Dec 2018 10:54:34 +0000 (10:54 +0000)
app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java [new file with mode: 0644]

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 (file)
index 0000000..2aee533
--- /dev/null
@@ -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);");
+    }
+}