Creation and storage of a dataset using TDBoid

144 views
Skip to first unread message

Stefan Zander

unread,
May 25, 2012, 12:35:38 PM5/25/12
to andr...@googlegroups.com
Dear Androjena community,

I was wondering how to create a in instance of a TDB database on an Android device;

Following the instructions given at the TDB wiki [1] regarding the creation of a dataset using the following lines of code

String _DATABASE = "/tdb/tdboid_db";
String _MODEL_NAME = "tdb_model";

Dataset dataset = TDBFactory.createDataset(_DATABASE);
Model model = dataset.getNamedModel(_MODEL_NAME);

results in a failed to store properties exception as well as some other listed subsequently:

05-25 18:14:43.966: E/c*.h*.h*.j*.t*.b*.f*.M*(7765): Failed to store properties: /tdb/tdboid_db/this.info
05-25 18:14:43.966: E/c*.h*.h*.j*.t*.b*.f*.M*(7765): java.io.FileNotFoundException: /tdb/tdboid_db/this.info (No such file or directory)
05-25 18:14:44.036: E/AndroidRuntime(7765): Caused by: com.hp.hpl.jena.tdb.base.block.BlockException: Failed to create FileBase
05-25 18:14:44.036: E/AndroidRuntime(7765): Caused by: java.io.FileNotFoundException: /tdb/tdboid_db/nodes.dat (No such file or directory)

Is there anything we missed or failed to consider?

Best regards,
Stefan

-----
[1] http://jenawiki.hpl.hp.com/wiki/TDB/JavaAPI

Stefan Zander

unread,
May 25, 2012, 12:44:25 PM5/25/12
to andr...@googlegroups.com
Sorry, forgot to mention that we tested the creation of TDBoid-backed RDF models using Android OS version 4.0.2 (API 14) and 2.2 (API 8)...

lencinhaus

unread,
May 25, 2012, 3:17:12 PM5/25/12
to androjena
This isn't related to TDBoid but to android itself: you can't create
the store in that location. An android app can only create files and
directories inside its own private "context" path or on external
storage such as sdcard or usb memory (provided it has the required
permission, see http://developer.android.com/guide/topics/data/data-storage.html
and http://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE).
If you want to write in your'apps context path in the internal memory,
you should do like this:

String _DATABASE = "/tdb/tdboid_db";
String _MODEL_NAME = "tdb_model";
File storeDir = getContext().getFileStreamPath(_DATABASE );
Dataset dataset =
TDBFactory.createDataset(storeDir.getAbsolutePath());
Model model = dataset.getNamedModel(_MODEL_NAME);

Hope this helps, bye!
lorenzo

Stefan Zander

unread,
May 29, 2012, 8:49:04 AM5/29/12
to andr...@googlegroups.com
Lorenzo, thank you very much for the answer and the information you provided -- it totally makes sense and everything works fine now!

I was initially assuming that the tdboid folder is created per default inside an application's private context path. Maybe it would be beneficial to put a small note into the tdboid readme file to help others getting started with tdboid...

Moreover, we are currently evaluating qualitative and quantitative features of available mobile triples stores and I am looking forward to sharing results with anybody interested.

Thanks again and best regards,
Stefan
Reply all
Reply to author
Forward
0 new messages