Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Hello, i have an application that was working fine till a customer upgraded his tablet to Android 5.0. The database was stored on the SD Card, but after the upgrade there is no access to it. I am trying to create the database on the default ultralite database location but with no success. Any help will be appreciated

string exStorageDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
dbLocation = System.IO.Path.Combine(exStorageDir, DatabaseName);
IConnection dBConnection = null;
IConfigPersistent Config = DatabaseManager.CreateConfigurationFileAndroid(dbLocation,ctx);
Config.CreationString = "collation=1253ELL;";
dBConnection = DatabaseManager.CreateDatabase(Config);

Object reference not set to an instance of an object at RetailMobile.Sync.GenerateDatabase (Android.Content.Context ctx) [0x002c3] in d:\Projects\RetailMobile\RetailMobile\Sync.cs:413 at RetailMobile.Main.OnCreate (Android.OS.Bundle bundle) [0x0011e] in d:\Projects\RetailMobile\RetailMobile\Main.cs:132

I tried with any other directory, not only external dir - files path dir, root dir, but always the same.

asked 08 Aug '15, 05:59

katalun4o's gravatar image

accept rate: 85%


I cannot run the code exactly as given, but I am able to successfully create an UltraLite database with code like this:

String exStorageDir = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
String dbLocation = exStorageDir + "/test.udb";
Context ctx = this;
Connection conn = null;
try {
    ConfigFileAndroid config = DatabaseManager.createConfigurationFileAndroid(dbLocation, ctx);
    conn = DatabaseManager.createDatabase(config);
catch (ULjException e) {
finally {
    if (conn != null) {
    try {
    catch (ULjException ex) {

Usually, one should put the database in "Android/data/<app-package-name>/files" below the external storage directory.

Also, you must have: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> in your AndroidManifest.xml.

(10 Aug '15, 15:37) Andy Quick
Replies hidden

Thank you for the answer Andy. I tried your sample but I got error again. The location I get on my tablet is "/storage/emulated/0/test.udb" and the error is

e {Java.Lang.UnsatisfiedLinkError: Exception of type 'Java.Lang.UnsatisfiedLinkError' was thrown. at Android.Runtime.JNIEnv.CallStaticObjectMethod (IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/7f0e3d3c/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1160 at Com.Ianywhere.Ultralitejni12.DatabaseManager.CreateDatabase (IConfiguration p0) [0x00000] in <filename unknown="">:0 at RetailMobile.Sync.CreateDatabase (Android.Content.Context ctx) [0x0001c] in d:\Projects\RetailMobile\RetailMobile\Sync.cs:76 --- End of managed exception stack trace --- java.lang.UnsatisfiedLinkError: com.ianywhere.ultralitejni12.implementation.JniDbMgr at com.ianywhere.ultralitejni12.DatabaseManager.createDatabase(Unknown Source) at retailmobile.Main.n_onCreate(Native Method) at retailmobile.Main.onCreate( at at at at at$800( at$H.handleMessage( at android.os.Handler.dispatchMessage( at android.os.Looper.loop( at at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke( at$ at } Java.Lang.UnsatisfiedLinkError

(10 Aug '15, 18:37) katalun4o

Oh, I was testing UltraLiteJ in SQLA v16. I did try v12 with an arm-v7a Android 5.0 emulator and that worked as well. Are you targeting 64-bit ARM? UnsatisfiedLinkError likely means that the system cannot find the native library, That should be in libs/armeabi in your project.

(11 Aug '15, 13:56) Andy Quick

Thanks Andy, I found what was causing the problem. The folder that "" should be in, must have the same name as the device’s architecture. So if you want to support different architectures you should put the file in all folders - "armeabi", "armeabi-v7a", "x86"... :)

permanent link

answered 19 Aug '15, 14:29

katalun4o's gravatar image

accept rate: 85%


Good, but FYI: is a native library built for ARM architectures and so will not work on x86. X86 support will be available in SQLA 17.0.

(19 Aug '15, 16:44) Andy Quick
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 08 Aug '15, 05:59

question was seen: 2,363 times

last updated: 19 Aug '15, 16:44