Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing database #48

Closed
fstephany opened this issue Feb 20, 2014 · 6 comments
Closed

Use existing database #48

fstephany opened this issue Feb 20, 2014 · 6 comments

Comments

@fstephany
Copy link
Contributor

I would like to use Sprinkles with an existing database. Right now, the database name is hardcoded in DbOpenHelper. It would be great to be able to open a database with another name bundled in the App.

@emilsjolander
Copy link
Owner

Known limitation, it hasn't been a priority but i'll try to get it into the next version 👍

@fstephany
Copy link
Contributor Author

Great! I've forked the repo and will give it a try today.

@fstephany
Copy link
Contributor Author

After a quick check, https://github.com/jgilfelt/android-sqlite-asset-helper does the trick quite nicely (but also subclass SQLiteOpenHelper).

I don't know if this use case is important enough to bloat Sprinkles with this feature (either by replicating some pieces of the sqlite-asset-helper or by including it as a dependency).

@fstephany
Copy link
Contributor Author

I've added a parameter to the Sprinkles init method: Sprinkles init(Context context, SQLiteDatabase db). This init manually set the sInstance variable of the DbOpenHelper (hacky!).
By doing so, sqlite-asset-helper handles the migration but I still can use Sprinkles for mapping my models.

All in all, isn't it a bit weird that the DB instance is held by the DbOpenHelper? Maybe the static db variable should in Sprinkles?

fstephany@241139e

@emilsjolander
Copy link
Owner

This feels like a duplicate of pull request #49. ok if i close this and we keep the discussion there? Regarding the static variables, it's not pretty and i would like to change it, not decided how yet though.

@fstephany
Copy link
Contributor Author

Ok, me can move the discussion in #49 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants