2

This is my demo project

public class SQLDemoActivity extends Activity {
    EventDataSQLHelper eventsData;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //you must set Context on SQLiteDatabase first
        SQLiteDatabase.loadLibs(this);
        String password = "foo123";
        eventsData = new EventDataSQLHelper(this);
        //then you can open the database using a password
        SQLiteDatabase db = eventsData.getWritableDatabase(password);
        for (int i = 1; i < 100; i++)
            addEvent("Hello Android Event: " + i, db);
        db.close();
        db = eventsData.getReadableDatabase(password);
        Cursor cursor = getEvents(db);
        showEvents(cursor);
        db.close();
    }
    @Override
    public void onDestroy() {
        eventsData.close();
    }
    private void addEvent(String title, SQLiteDatabase db) {
        ContentValues values = new ContentValues();
        values.put(EventDataSQLHelper.TIME, System.currentTimeMillis());
        values.put(EventDataSQLHelper.TITLE, title);
        db.insert(EventDataSQLHelper.TABLE, null, values);
    }
    private Cursor getEvents(SQLiteDatabase db) {
        Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null, null, null);
        startManagingCursor(cursor);
        return cursor;
    }
    private void showEvents(Cursor cursor) {
        StringBuilder ret = new StringBuilder("Saved Events:\n\n");
        while (cursor.moveToNext()) {
            long id = cursor.getLong(0);
            long time = cursor.getLong(1);
            String title = cursor.getString(2);
            ret.append(id + ": " + time + ": " + title + "\n");
        }
        Log.i("sqldemo",ret.toString());
    }
}

I am getting the following error how i clean the errors. The following links as demo project is https://github.com/sqlcipher/android-database-sqlcipher.

04-12 12:53:20.229: E/AndroidRuntime(7413): java.lang.UnsatisfiedLinkError: Couldn't load stlport_shared: findLibrary returned null

04-12 12:53:20.229: E/AndroidRuntime(7413):     at java.lang.Runtime.loadLibrary(Runtime.java:429)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at java.lang.System.loadLibrary(System.java:554)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:142)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:137)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at example.SQLDemoActivity.onCreate(SQLDemoActivity.java:20)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at android.os.Handler.dispatchMessage(Handler.java:99)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at android.os.Looper.loop(Looper.java:123)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-12 12:53:20.229: E/AndroidRuntime(7413):     at java.lang.reflect.Method.invokeNative(Native Method)
04-12 12:53:20.229: E/AndroidRuntime(7413):     at java.lang.reflect.Method.invoke(Method.java:507)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

04-12 12:53:20.229: E/AndroidRuntime(7413):     at dalvik.system.NativeStart.main(Native Method)<

3 Answers 3

2

Make sure that your project has the libs/ directory contents set up properly. Not only do you need JAR files, but you need subdirectories with .so files for each CPU architecture that you intend to support, such as you see in the libs/ directory of this sample project.

Sign up to request clarification or add additional context in comments.

1 Comment

i have the same error , i did your solution but it keeps throwing the above exception , note i am using AndroidStudio 0.5.1 and using Emulator kitkat .
1

I had the same error. Here the solution that worked for me.

Create a folder named jniLibs near your java folder and place there all directories (or just directories which architecture you intend to support) with *.so files.

It must look like this.

enter image description here

If it works for you, you don't need to have this folders in your libs folder.

P.S. I use Android Studio.

Comments

0

Within your App, inside your build.gradle file make sure you have the following lines:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/sqlcipher-javadoc.jar')
compile files('libs/sqlcipher.jar')

}

Also right click your project, open module settings and select the dependencies tab. Make sure sqlcipher-javadoc.jar and sqlcipher.jar is listed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.