Skip to content

Commit

Permalink
Added method for creation of database if no database files are provid…
Browse files Browse the repository at this point in the history
…ed and we need to create empty database in application data directory.
  • Loading branch information
ranaparamveer committed Jul 25, 2018
1 parent 989594c commit 684f826
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 684f826

Please sign in to comment.