From 684f82684fdcc8381aab924dba9fd906e4823e47 Mon Sep 17 00:00:00 2001 From: ranaparamveer Date: Wed, 25 Jul 2018 18:32:54 +0530 Subject: [PATCH] Added method for creation of database if no database files are provided and we need to create empty database in application data directory. --- README.markdown | 2 +- .../com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 86a859a..210682d 100644 --- a/README.markdown +++ b/README.markdown @@ -22,7 +22,7 @@ If you are using the Gradle build system, simply add the following dependency in ```groovy dependencies { - implementation 'com.github.ranaparamveer:android-sqlite-asset-helper:v2.0.6' + implementation 'com.github.ranaparamveer:android-sqlite-asset-helper:v2.0.7' } ``` diff --git a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java index 8883ccc..69864b7 100755 --- a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java +++ b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java @@ -439,6 +439,10 @@ private SQLiteDatabase returnDatabase() { Log.i(TAG, "successfully opened database " + mName); db = SQLiteDatabase.openDatabase(getDatabasePath(), mFactory, SQLiteDatabase.OPEN_READWRITE); }else if (createNewIfNotExist) { + File f = new File(mDatabasePath + "/"); + if (!f.exists()) { + f.mkdirs(); + } db = SQLiteDatabase.openOrCreateDatabase(getDatabasePath(), mFactory, new DatabaseErrorHandler() { @Override public void onCorruption(SQLiteDatabase sqLiteDatabase) {