Changes

Jump to navigation Jump to search
1,316 bytes added ,  13:25, 10 April 2014
no edit summary
It is possible to create an Android port of BaseX.
Therefore the present tutorial outlines the creation of a BaseX Android library, which can be used in any other application project.
For the creation of the library the IDE Android Studio[http://developer.android.com/sdk/installing/studio.html] is used, but the steps are more or less equal in using the Eclipse IDE Eclipse.
----
== Using the BaseX Android Library ==
To use the BaseX library the above created BaseXDatabase class can be extended with additional methods which are delegating requests to the BaseX database and return the results.<br>
An example of this can be seen in the following code:
<pre class="brush:java">
public String executeXQuery(String query) throws IOException {
if(basexContext != null)
return new XQuery(query).execute(basexContext);
else
Log.e("BaseXDatabase", "No context");
return "";
}
</pre>
This methods of the BaseXDatabase class can now be used in every Android application which includes the created BaseX Android library.<br>
It is possible to create a .jar, or an .aar[http://tools.android.com/tech-docs/new-build-system/aar-format] file out of the BaseX library, by just building the source code.
This file need to be copied inside the lib folder of the Android project which wants to use the library. Additionally the build file of the application needs to be adjusted to use the library.<br>
Using Gradle, the Android build system, it can be done by adding the following line to the gradle build file. This tells the build system that every library, inside the libs folder, is being compiled into the projects file.
<pre class="brush:java">
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
</pre>
administrator, editor
10

edits

Navigation menu