-
Notifications
You must be signed in to change notification settings - Fork 308
Data export and import #310
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
Comments
Wow~ Could you please share some time schedule for this feature? @greenrobot |
Extremely useful feature! Looking forward! |
This would greatly simplify some work I'm doing -- I'd love to just download a fully built MDB file to the app, or some intermediary format that can be "automatically" parsed to replace the on-device database. |
It's weird but this "feature" already available. When I looked for how to do it I found this issue on github and thought that it's impossible to pack initial dataset into my app. But then I noticed question in FAQ section of official site: Can I ship my app with a pre-built database? As for me it's enough. Maybe it would be useful for thoose who looking for solution. |
@Yazon2006 where are you find the FAQ? would you please share the url? |
@yocn in very unexpected place: http://objectbox.io/faq/ |
@greenrobot So, Is the Can I ship my app with a pre-built database? in FAQ recommend for developers? |
@yocn Yes? Not sure what you are getting at with recommended. -ut |
So we just double checked: the data.mdb file works across plaforms (x64, ARM, 32 and 64 bit). Thus, the FAQ is still valid. |
@greenrobot So,If I want to develop with a preset data.mdb, my process is: |
Yes, this is mostly correct. Just a few comments:
I think it makes sense to make a convenient method to provision a default db file, that copies some file if the actual db file does not exist. What do you think? |
I'm just implementing a method like this: |
Check 1.4.4 for |
@greenrobot Really thanks, I'll check it later. |
@greenrobot
Is My invoke method correct? |
Looks good! Online JavaDocs are still to be updated... |
@greenrobot but I cannot get the |
@yocn Will only be called if there's no DB yet. |
@greenrobot Yes~~~forget it , first run is normal, appreciate it. |
@greenrobot But I have another question,Whether the mdb file is cross-platform,For example, I am generating on x86, can I use it on armbi-v7a ? I think I found the answer. It is cross-platform, Sorry to disturb |
Do I get this right, you are creating your databases on runtime only, so each Do I get this right, that it's still this way today? If so, how does this get the "appreciation" it seems to get with 2830 stars? |
@ErfolgreichCharismatisch ObjectBox persists data across app starts of course. |
Updated link in first comment to point to new FAQ page: https://docs.objectbox.io/faq#can-i-ship-my-app-with-a-pre-built-database |
What is the best way to generate an initial data.mdb and keep it readable? With SQLite, we just need to write some sql scripts and commit to VCS. It is just text file, so we can understand the initial data. I suggest add a feature to import json file (ex. |
Hi, don't know if this was mentioned anywhere else but is there any way of reading the .mdb file directly? I'd like to allow the user to be able to import a database, either this deletes the current one and puts the imported one into the file system(should be easy enough) or (even better) the entries in the imported database are added to those in the current database. I don't know if this is already implemented or if you have a recommended way of tackling this, I thought of reading all the entries and putting them in a .json file and then that is what's exported. And when we import we just read the .json file and persist entries from the .json file, using GSON. Any help would be appreciated, many thanks and thank you for making my life easier with Objectbox! |
I keep getting this This is really frustrating as I don't know what I am doing wrong. [edit] Got it to work by copying the default.json from my Java project to the android project, so that the IDs match. Don't know what caused the confusion though. |
@Benjoyo This sounds like you found out that your model file changed unexpectedly. Make sure to also commit it to version control. -Uwe |
Allow an data (and optionally the data model) to be exported and imported. This would simplify packaging an initial dataset with an app.
Possible implementations: json.gz, binary.gz, raw dump.
Update: you can prepare a data.mdb file to have preloaded data in your app; see FAQ.
The text was updated successfully, but these errors were encountered: