I’m using this code to store SQLite DB to sdcard location (location on device /mnt/sdcard/MiniMate ):
string libraryPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
libraryPath = System.IO.Path.Combine(libraryPath, "MiniMate");
if (!System.IO.Directory.Exists(libraryPath)) System.IO.Directory.CreateDirectory(libraryPath);
string path = System.IO.Path.Combine(libraryPath, sqliteFilename);
It works perfect when I using deploying from Visual studio to device; However if I create .apk and install it on device it gives me an error “21”. Looks like it’s not permissions to do something with DB, I have “Constraint” error when I trying to insert something in DB.
Does somebody know this issue?
I’m not looking to move DB to different default location, Thank you!
My Manifest file :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.prismvs.minimate" android:versionCode="14" android:versionName="14">
<uses-sdk android:targetSdkVersion="12" android:minSdkVersion="12" />
<application android:icon="@drawable/icon" android:label="MiniMate">
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_ORIENTATION" />
<uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
<uses-permission android:name="android.permission.READ_OWNER_DATA" />
</manifest>
I posted this a few days ago and spent so much time for find a problem because I moved in wrong dirrection, so I want to share this experience maybe it will help somebody to fix their issues with SQLite + Mono for Android:
E/SQLiteLog(32375): (21) API called with NULL prepared statement
E/SQLiteLog(32375): (21) misuse at line 63243 of [00bb9c9ce4]
It was not happen for debug version, so what I did for fixinfg this problem:
On Visual studion project properties -> Mono Android Options -> Linking: I set “SDK assemblies Only” instead of “SDK and User assemblies”
This error is disappear.