I m getting unsatisfied link error in native method
Logcat main exception
UnsatisfiedLinkError: Native method not found: rg.sqlite.database.sqlite.S
I have resolved this issue my self by adding
System.loadLibrary("sqliteX");
To each method where they are created
LIKE THIS:
public HashMap<String, ArrayList<String>> word_quiz(String qry) {
System.loadLibrary("sqliteX");
ArrayList<String> list1 = new ArrayList<String>();
ArrayList<String> list2 = new ArrayList<String>();
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(DB_PATH+ "/sk1.db", null);
Cursor mcursor = db.rawQuery(qry, null);
try {
mcursor.moveToFirst();
do {
list1.add(mcursor.getString(0));
list2.add(mcursor.getString(1));
} while (mcursor.moveToNext());
} catch (IndexOutOfBoundsException e) {
if (MainActivity.logcat_status) {
Log.e("Error", e + "");
}
}
mcursor.close();
mcursor = null;
HashMap<String, ArrayList<String>> final_list = new HashMap<String, ArrayList<String>>();
final_list.put("list1", list1);
final_list.put("list2", list2);
db.close();
return final_list;
}
Now its working fine
I think I can also use a constructor to load the library "sqliteX"
Thanks guys for considering my question :)
As opposed to the accepted answer consider inserting the call to the System.loadLibrary function only once, e.g. into the DbHelper.
public class MyDbHelper extends SQLiteOpenHelper {
static {
System.loadLibrary("sqliteX");
}
}
The exception originates from your code at com.example.samplesqlitedb.MainActivity$2.onClick()
at com/example/samplesqlitedb/MainActivity.java:56, but System.loadLibrary()
is called from org.sqlite.app.customsqlite.CustomSqlite.run_the_tests()
. There is no evidence that the org.sqlite.app.customsqlite.CustomSqlite
activity was even loaded into JVM when this happened.
I would suggest to load libsqliteX.so
from the static constructor of org.sqlite.database.sqlite.SQLiteConnection
class. Maybe you can find some better place - e.g. com.example.samplesqlitedb.SearchDataDB
class, or the class in your app that extends android.app.Application
(if you have such).