Giter Club home page Giter Club logo

android-database-sqlcipher's Introduction

Deprecated Library

The android-database-sqlcipher project has been officially deprecated. The long-term replacement is sqlcipher-android. Instructions for migrating from android-database-sqlcipher to sqlcipher-androidmay be found here.

Download Source and Binaries

The latest AAR binary package information can be here, the source can be found here.

Compatibility

SQLCipher for Android runs on Android from 5.0 (API 21), for armeabi-v7a, x86, x86_64, and arm64_v8a architectures.

Contributions

We welcome contributions, to contribute to SQLCipher for Android, a contributor agreement needs to be submitted. All submissions should be based on the master branch.

An Illustrative Terminal Listing

A typical SQLite database in unencrypted, and visually parseable even as encoded text. The following example shows the difference between hexdumps of a standard SQLite database and one implementing SQLCipher.

~ sjlombardo$ hexdump -C sqlite.db
00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite format 3.|
…
000003c0 65 74 32 74 32 03 43 52 45 41 54 45 20 54 41 42 |et2t2.CREATE TAB|
000003d0 4c 45 20 74 32 28 61 2c 62 29 24 01 06 17 11 11 |LE t2(a,b)$…..|
…
000007e0 20 74 68 65 20 73 68 6f 77 15 01 03 01 2f 01 6f | the show…./.o|
000007f0 6e 65 20 66 6f 72 20 74 68 65 20 6d 6f 6e 65 79 |ne for the money|

~ $ sqlite3 sqlcipher.db
sqlite> PRAGMA KEY=’test123′;
sqlite> CREATE TABLE t1(a,b);
sqlite> INSERT INTO t1(a,b) VALUES (‘one for the money’, ‘two for the show’);
sqlite> .quit

~ $ hexdump -C sqlcipher.db
00000000 84 d1 36 18 eb b5 82 90 c4 70 0d ee 43 cb 61 87 |.?6.?..?p.?C?a.|
00000010 91 42 3c cd 55 24 ab c6 c4 1d c6 67 b4 e3 96 bb |.B?..?|
00000bf0 8e 99 ee 28 23 43 ab a4 97 cd 63 42 8a 8e 7c c6 |..?(#C??.?cB..|?|

~ $ sqlite3 sqlcipher.db
sqlite> SELECT * FROM t1;
Error: file is encrypted or is not a database

(example courtesy of SQLCipher)

Application Integration

You have a two main options for using SQLCipher for Android in your app:

  • Using it with Room or other consumers of the androidx.sqlite API

  • Using the native SQLCipher for Android classes

In both cases, you will need to add a dependency on net.zetetic:android-database-sqlcipher, such as having the following line in your module's build.gradle dependencies closure:

implementation "net.zetetic:android-database-sqlcipher:4.5.3"
implementation "androidx.sqlite:sqlite:2.1.0"

(replacing 4.5.3 with the version you want)

Using SQLCipher for Android With Room

SQLCipher for Android has a SupportFactory class in the net.sqlcipher.database package that can be used to configure Room to use SQLCipher for Android.

There are three SupportFactory constructors:

  • SupportFactory(byte[] passphrase)
  • SupportFactory(byte[] passphrase, SQLiteDatabaseHook hook)
  • SupportFactory(byte[] passphrase, SQLiteDatabaseHook hook, boolean clearPassphrase)

All three take a byte[] to use as the passphrase (if you have a char[], use SQLiteDatabase.getBytes() to get a suitable byte[] to use).

Two offer a SQLiteDatabaseHook parameter that you can use for executing SQL statements before or after the passphrase is used to key the database.

The three-parameter constructor also offers clearPassphrase, which defaults to true in the other two constructors. If clearPassphrase is set to true, this will zero out the bytes of the byte[] after we open the database. This is safest from a security standpoint, but it does mean that the SupportFactory instance is a single-use object. Attempting to reuse the SupportFactory instance later will result in being unable to open the database, because the passphrase will be wrong. If you think that you might need to reuse the SupportFactory instance, pass false for clearPassphrase.

Then, pass your SupportFactory to openHelperFactory() on your RoomDatabase.Builder:

final byte[] passphrase = SQLiteDatabase.getBytes(userEnteredPassphrase);
final SupportFactory factory = new SupportFactory(passphrase);
final SomeDatabase room = Room.databaseBuilder(activity, SomeDatabase.class, DB_NAME)
  .openHelperFactory(factory)
  .build();

Now, Room will make all of its database requests using SQLCipher for Android instead of the framework copy of SQLCipher.

Note that SupportFactory should work with other consumers of the androidx.sqlite API; Room is merely a prominent example.

Using SQLCipher for Android's Native API

If you have existing SQLite code using classes like SQLiteDatabase and SQLiteOpenHelper, converting your code to use SQLCipher for Android mostly is a three-step process:

  1. Replace all android.database.sqlite.* import statements with ones that use net.sqlcipher.database.* (e.g., convert android.database.sqlite.SQLiteDatabase to net.sqlcipher.database.SQLiteDatabase)

  2. Before attempting to open a database, call SQLiteDatabase.loadLibs(), passing in a Context (e.g., add this to onCreate() of your Application subclass, using the Application itself as the Context)

  3. When opening a database (e.g., SQLiteDatabase.openOrCreateDatabase()), pass in the passphrase as a char[] or byte[]

The rest of your code may not need any changes.

An article covering both integration of SQLCipher into an Android application as well as building the source can be found here.

ProGuard

For applications which utilize ProGuard, a few additional rules must be included when using SQLCipher for Android. These rules instruct ProGuard to omit the renaming of the internal SQLCipher classes which are used via lookup from the JNI layer. It is worth noting that since SQLCipher or Android is based on open source code there is little value in obfuscating the library anyway. The more important use of ProGuard is to protect your application code and business logic.

-keep,includedescriptorclasses class net.sqlcipher.** { *; }
-keep,includedescriptorclasses interface net.sqlcipher.** { *; }

Building

In order to build android-database-sqlcipher from source you will need both the Android SDK, Gradle, Android NDK, SQLCipher core source directory, and an OpenSSL source directory. We currently recommend using Android NDK LTS version 23.0.7599858.

To complete the make command, the ANDROID_NDK_HOME environment variable must be defined which should point to your NDK root. Once you have cloned the repo, change directory into the root of the repository and run the following commands:

SQLCIPHER_ROOT=/some/path/to/sqlcipher-folder \
OPENSSL_ROOT=/some/path/to/openssl-folder \
SQLCIPHER_CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2" \
SQLCIPHER_ANDROID_VERSION="4.5.3" \
make build-release

You may specify other build flags/features within SQLCIPHER_CFLAGS, however, specifying -DSQLITE_HAS_CODEC and -DSQLITE_TEMP_STORE is necessary in the list of flags.

License

The Android support libraries are licensed under Apache 2.0, in line with the Android OS code on which they are based. The SQLCipher code itself is licensed under a BSD-style license from Zetetic LLC. Finally, the original SQLite code itself is in the public domain.

android-database-sqlcipher's People

Contributors

abeluck avatar afzalive avatar brodybits avatar commonsguy avatar developernotes avatar eighthave avatar fairchild88 avatar hannesa2 avatar illarionov avatar jeffdcamp avatar n8fr8 avatar nuumio avatar sjlombardo avatar sschuberth avatar superfell avatar tapchicoma avatar zackjp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-database-sqlcipher's Issues

SQLiteOpenHelper not calling onUpgrade

Hello,
I have upgraded my version of SQLCipher from 1.1.0 to 2.0.8, in order to get this to work I require to call upgradeDatabaseFormatFromVersion1To2 on the 1.1.0 DBs. How I have tried to implement this is to increase the DB version and then in the onUpgrade function call the upgradeDatabaseFormatFromVersion1To2 function.

The problem I am having is the onUpgrade function is not being called when I create my SQLiteOpenHelper class. I have check the versions of the DB using getVersion(), they are correct. I have also manually called the upgradeDatabaseFormatFromVersion1To2 function on a 1.1 DB and when I import the DB it works fine.

Any ideas why the onUpgrade is not firing, I thought of function template changes, or maybe the order in which I am calling these functions.

info.guardianproject.database.sqlcipher.SQLiteException still thrown

On a bad passphrase entry I got this:

03-07 02:14:12.832: E/AndroidRuntime(1503): java.lang.NoClassDefFoundError: info/guardianproject/database/sqlcipher/SQLiteException
03-07 02:14:12.832: E/AndroidRuntime(1503): at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
03-07 02:14:12.832: E/AndroidRuntime(1503): at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2015)
03-07 02:14:12.832: E/AndroidRuntime(1503): at net.sqlcipher.database.SQLiteDatabase.(SQLiteDatabase.java:1881)
03-07 02:14:12.832: E/AndroidRuntime(1503): at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:864)

NullPointerException when launching example app

Hi,

First of all thanks so much for this project, I think is really important at the moment as there is not a secure way to store critical information in an android device, so this project fills an important gap.

At the moment the project throws a NullPointerException when executing as the EventDataSQLHelper object is still null when the getWritableDatabase is called on him in the onCreate method. Just that!

Thanks so much for your hard work.

SQLCipher Fatal Exception on Android 4.0

Running on a Galaxy Nexus phone with Android 4.0. (Works find on 2.2 and 2.3.) The following exception is raised when calling getReadableDatabase().

12-15 16:47:27.819: ERROR/AndroidRuntime(28459): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{xyz.activity.SplashActivity}: info.guardianproject.database.sqlcipher.SQLiteException: not an error
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
at android.app.ActivityThread.access$600(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4340)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: info.guardianproject.database.sqlcipher.SQLiteException: not an error
at info.guardianproject.database.sqlcipher.SQLiteDatabase.dbopen(Native Method)
at info.guardianproject.database.sqlcipher.SQLiteDatabase.(SQLiteDatabase.java:1870)
at info.guardianproject.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:863)
at info.guardianproject.database.sqlcipher.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:183)

Lib won't load on 2.3.3

From the list:
http://lists.mayfirst.org/pipermail/guardian-dev/2011-July/000306.html

see the logcat PNG screenshot

Hi guys, first of all, sorry for my english, I attached a screenshot with
the Android logcat, and the exceptio. In the left side you can see the
structure of the files (I try to copy from yours projects).
If you can help me with the steps from zero, that I need to do for
develop
an app for Android I was very very grateful.

PHONE_NUMBERS_EQUAL no longer works

It seems that the PHONE_NUMBERS_EQUAL function from SQLite no longer works once the database is switched over to SQLCipher. It's throwing the following error:
info.guardianproject.datbase.sqlcipher.SQLiteException: no such function: PHONE NUMBERS EQUAL
The code was working correctly immediately before being switched to SQLCipher.
This might be an issue with SQLCipher or an issue with an extension that doesn't interact properly with SQLCipher as opposed to SQLite.

Possible Feature: Compression

Problem with encrypted data: You cannot compress it efficiently.

In my case, I have a 50 MB database which is only like 10 MB zipped. Obviously this is no longer possible if the database is encrypted.

My suggestion is to add an compression layer which can compress the unencrypted chunks and encrypt it afterwards.

report a crash bug of sqlcipher on Android 4.0.3

the problem i met here is :
when you use beginTransaction() function, if there are too many sql statements lines between beginTransaction() function and endTranaction() . the code will crash and return error code "sqlite SQL logic error or missing database "
and code here is example, the problem is Complete reproducibility.

[code]
db = SQLiteDatabase.openOrCreateDatabase(databaseFile, "test123", null);
// LOG.d("db", "call from" + Thread.currentThread().getId());
String _ID = "_id";
db.beginTransaction();
db.execSQL(" CREATE TABLE IF NOT EXISTS ttt (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
db.execSQL(" CREATE TABLE IF NOT EXISTS rwerw (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
db.execSQL(" CREATE TABLE IF NOT EXISTS erwe (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
db.execSQL(" CREATE TABLE IF NOT EXISTS werwe (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
db.execSQL(" CREATE TABLE IF NOT EXISTS wqrwe (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
db.execSQL(" CREATE TABLE IF NOT EXISTS werwerwet (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
db.execSQL(" CREATE TABLE IF NOT EXISTS twee (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
db.execSQL(" CREATE TABLE IF NOT EXISTS ouio (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");

    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio1 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio2 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio3 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio4 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");

    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio41 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio42 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio43 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio44 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio45 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio46 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio47 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio48 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.execSQL(" CREATE TABLE IF NOT EXISTS ouio49 (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, ttt TEXT);");
    db.endTransaction();

[/code]

Any roadmap or declared release date for v2?

Hello,
Sorry if this is already discussed. Is there any roadmap or declared release date for stable v2? The github milestone shows it passed 4 months ago? Any update on that?

Thanks in advance for your time!

file handle leak?

I have a test suite for my app that does a lot of open/rawQuery/execSQl/close calls on the database, using the standard SQLiteDatabase this test suite runs fine to completion (tested on both 2.1 & 2.2). When i switch to using sqlcipher the test suite gets about 50% through and the stops with a bunch of errors that all seem related to this log line

E/MemoryHeapBase( 1028): error creating ashmem region: Too many open files
E/CursorWindow( 1028): CursorWindow heap allocation failed
I/TestRunner( 1028): ----- begin exception -----
I/TestRunner( 1028):
I/TestRunner( 1028): java.lang.IllegalStateException: Couldn't init cursor window

Are you aware of any file handle leaks, or areas where you may manage file handles differently to the OS supplied SQLiteDatabase ? I'm working on putting together a simple repo case for this.

I've seen this with v0.4 & v0.3 releases.

SQlitecipher and SQlite on android

I have a question about SQliteCipher being based on Sqlite, does it tend to create a new db which is compatible with Sqlite API and db.
I understand Sqlitecipher is forked off, how do we know its fully compliant with Sqlite in Android 2.x and 3.X

thanks!

regards,
S.Abdullah

tags

It'd be really useful if you would create tags in the repo that matched the released downloads, right now, i have no idea which commit v0.4 actually is.

Thanks
Simon

Application crashes if Cursor content is bigger than 1MB

I know that this is a limit hard-coded in the CursorWindow implementation...
However I need to store a file in the encrypted db as a blob, but since it is bigger than 1mb I cannot retrive it without causing a crash... Is there a way to bypass this limitation? For example, is there a way to query the blob in chunks of max 1mb?

Using Content Provider

How can we use contentProvider with the package? when i m trying it, it says unable to get the MyContentProvider.

no such function: sqlcipher_export

Hello,

I was trying to run this code (Android/Java/Eclipse)

private SQLiteDatabase vgpdb;

    SQLiteDatabase.loadLibs(appcontext);

vgpdb = SQLiteDatabase.openOrCreateDatabase(database1, "Test1234, null);
vgpdb.execSQL("ATTACH DATABASE '/mnt/sdcard/Empty.sqlite' AS plaintext KEY '';");
vgpdb.execSQL("SELECT sqlcipher_export('plaintext');"); 
    vgpdb.execSQL("DETACH DATABASE plaintext;");
vgpdb.close();

When it gets to the sqlcipher_export line I get an exception, "05-10 10:13:35.420: E/Database(13730): Failure 1 (no such function: sqlcipher_export) on 0x1b8c030 when preparing 'SELECT sqlcipher_export('plaintext');'."

I am using the Anrdroid 1.1.0 package with the assets zip file icudt46l.zip, any advice would be helpfull.

thanks

SQLCipher under Android 4.0.3

Hello,

I am writing an Android APP using SQLite, I looked at using SQLCipher but this crashes, on first DB commands, I have since sorted library loading issues and got the icu46.zip patch, still crashes.

I then downloaded NoteCipher to see if this worked and it did not.

Does this mean the SQLCipher will not work in my Android enviroment ?

I have looked at some other forum questions and some developers are re-building the SQLCipher from source themselves. If you want I can provide traces from logcat but it appears to be a similar issue as reported in issues #34 and #36.

Any suggestions ?

Error copying icu data fileicudt46l.zip on Android 4.1.1

Environment: Android 4.1.1 (Nexus S), 4.1 (ARM emulator); SQLCipher for Android 2.0.8

Symptoms: On getWriteableDatabase() call in SQLiteDatabase, an error is logged to LogCat (Error copying icu data fileicudt46l.zip), and the attempt to open the database fails in dbopen():

09-12 09:14:34.004: I/TestRunner(16903): net.sqlcipher.database.SQLiteException: not an error
09-12 09:14:34.004: I/TestRunner(16903): at net.sqlcipher.database.SQLiteDatabase.dbopen(Native Method)
09-12 09:14:34.004: I/TestRunner(16903): at net.sqlcipher.database.SQLiteDatabase.(SQLiteDatabase.java:1952)
09-12 09:14:34.004: I/TestRunner(16903): at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:902)
09-12 09:14:34.004: I/TestRunner(16903): at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:945)
09-12 09:14:34.004: I/TestRunner(16903): at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)

The same code works fine on 4.0.3 (emulator).

You can see this in action via https://github.com/commonsguy/cwac-prefs (a SharedPreferences implementation that uses SQLCipher for Android as a backing store). The test suite (in the tests/ sub-project) runs fine on 4.0.3 and fails on 4.1.x.

Andorid 3.0 support

This is just a query not a real issue.
As i'm exploring the sqlitecipher android here, it says it only supports 2.2 and 2.3.
What about 3.x (honey comb). Are there any known limitations, or is it just not tested yet.

CursorWindow need to grow crash

I am using the libraries that come with SQLCipherForAndroid-SDK-0.0.5-Beta.tar.gz. My database is created successfully. My first sql query works fine but 2nd one("SELECT count(A) FROM B)" fails when I try to use cursor object returned(which is not null). I test on Samsung Galaxy Gio device.

According to error, it seems that memory allocation fails. (I don't understand why this >2MB allocation is needed, since my query returns empty result. Galaxy Gio is a cheap device, so maybe less heap memory allowed per app?)

The code that leads to this crash is cursor.moveToNext(); but also other calls cursor methods cause this crash. A weird thing is that, this crash doesn't happen if I dig into attached jar's source code with eclipse.

My program works fine if I don't use sqlcipher..

I get the following error in logcat:

10-19 10:55:13.483: ERROR/CursorWindow(2770): need to grow: mSize = 2097152, size = 9, freeSpace() = 0, numRows = 1
10-19 10:55:13.591: INFO/DEBUG(2187): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-19 10:55:13.591: INFO/DEBUG(2187): Build fingerprint: 'samsung/GT-S5660/GT-S5660/GT-S5660:2.2.1/FROYO/XXKC7:user/release-keys'
10-19 10:55:13.591: INFO/DEBUG(2187): pid: 2770, tid: 2770 >>> com.MyProject <<<
10-19 10:55:13.591: INFO/DEBUG(2187): signal 11 (SIGSEGV), fault addr 4f16c448
10-19 10:55:13.591: INFO/DEBUG(2187): r0 4f16c448 r1 00000000 r2 00000001 r3 80000000
10-19 10:55:13.591: INFO/DEBUG(2187): r4 00000000 r5 00000000 r6 00000000 r7 00000000
10-19 10:55:13.591: INFO/DEBUG(2187): r8 00000009 r9 00000000 10 00000001 fp 00000064
10-19 10:55:13.591: INFO/DEBUG(2187): ip 00000000 sp beaed430 lr 00000000 pc afd0f460 cpsr 80000010
10-19 10:55:13.591: INFO/DEBUG(2187): d0 0000002a42280000 d1 3ff0000042280000
10-19 10:55:13.591: INFO/DEBUG(2187): d2 bfd3441350baf6de d3 c1493000c1323800
10-19 10:55:13.591: INFO/DEBUG(2187): d4 4900000040dcb000 d5 000000000006e580
10-19 10:55:13.601: INFO/DEBUG(2187): d6 4515a00000000800 d7 40800000c48ee000
10-19 10:55:13.601: INFO/DEBUG(2187): d8 0000000000000000 d9 0000000000000000
10-19 10:55:13.601: INFO/DEBUG(2187): d10 0000000000000000 d11 0000000000000000
10-19 10:55:13.601: INFO/DEBUG(2187): d12 0000000000000000 d13 0000000000000000
10-19 10:55:13.601: INFO/DEBUG(2187): d14 0000000000000000 d15 0000000000000000
10-19 10:55:13.601: INFO/DEBUG(2187): scr 80000012
10-19 10:55:13.651: INFO/DEBUG(2187): #00 pc 0000f460 /system/lib/libc.so
10-19 10:55:13.651: INFO/DEBUG(2187): #1 pc 00002708 /data/data/com.MyProject/lib/libdatabase_sqlcipher.so
10-19 10:55:13.651: INFO/DEBUG(2187): #2 pc 00003b34 /data/data/com.MyProject/lib/libdatabase_sqlcipher.so
10-19 10:55:13.651: INFO/DEBUG(2187): #3 pc 000170b4 /system/lib/libdvm.so
10-19 10:55:13.651: INFO/DEBUG(2187): #4 pc 000039d6 /data/data/com.MyProject/lib/libdatabase_sqlcipher.so
10-19 10:55:13.651: INFO/DEBUG(2187): code around pc:
10-19 10:55:13.651: INFO/DEBUG(2187): afd0f440 e213301c 0a000008 e1530002 8202301c
10-19 10:55:13.661: INFO/DEBUG(2187): afd0f450 e0422003 e1b03e03 28a04002 28a04002
10-19 10:55:13.661: INFO/DEBUG(2187): afd0f460 48a04002 e1b03103 24801004 e2522020
10-19 10:55:13.661: INFO/DEBUG(2187): afd0f470 e1a03001 4a000002 e2522020 e8a050fa
10-19 10:55:13.661: INFO/DEBUG(2187): afd0f480 2afffffc e2822020 e1b02e02 28a0500a
10-19 10:55:13.661: INFO/DEBUG(2187): code around lr:
10-19 10:55:13.661: INFO/DEBUG(2187): stack:
10-19 10:55:13.661: INFO/DEBUG(2187): beaed3f0 4410eab4
10-19 10:55:13.661: INFO/DEBUG(2187): beaed3f4 44332464 /dev/ashmem/dalvik-LinearAlloc (deleted)
10-19 10:55:13.661: INFO/DEBUG(2187): beaed3f8 00000000
10-19 10:55:13.661: INFO/DEBUG(2187): beaed3fc 898c75f3
10-19 10:55:13.661: INFO/DEBUG(2187): beaed400 afd4172c /system/lib/libc.so
10-19 10:55:13.661: INFO/DEBUG(2187): beaed404 002803d8 [heap]
10-19 10:55:13.661: INFO/DEBUG(2187): beaed408 00000009
10-19 10:55:13.661: INFO/DEBUG(2187): beaed40c 00000000
10-19 10:55:13.661: INFO/DEBUG(2187): beaed410 81505128 /data/data/com.MyProject/lib/libdatabase_sqlcipher.so
10-19 10:55:13.661: INFO/DEBUG(2187): beaed414 815025f5 /data/data/com.MyProject/lib/libdatabase_sqlcipher.so
10-19 10:55:13.661: INFO/DEBUG(2187): beaed418 815043c0 /data/data/com.MyProject/lib/libdatabase_sqlcipher.so
10-19 10:55:13.661: INFO/DEBUG(2187): beaed41c 00200000 [heap]
10-19 10:55:13.661: INFO/DEBUG(2187): beaed420 00000009
10-19 10:55:13.661: INFO/DEBUG(2187): beaed424 00000000
10-19 10:55:13.661: INFO/DEBUG(2187): beaed428 df002777
10-19 10:55:13.661: INFO/DEBUG(2187): beaed42c e3a070ad
10-19 10:55:13.661: INFO/DEBUG(2187): #00 beaed430 4f16c448
10-19 10:55:13.661: INFO/DEBUG(2187): beaed434 002803d8 [heap]
10-19 10:55:13.661: INFO/DEBUG(2187): beaed438 4f16c448
10-19 10:55:13.661: INFO/DEBUG(2187): beaed43c 4eeec008 /dev/ashmem/CursorWindow (deleted)
10-19 10:55:13.661: INFO/DEBUG(2187): beaed440 00280448 [heap]
10-19 10:55:13.671: INFO/DEBUG(2187): beaed444 8150270b /data/data/com.MyProject/lib/libdatabase_sqlcipher.so
10-19 10:55:13.671: INFO/DEBUG(2187): #1 beaed448 00000000
10-19 10:55:13.671: INFO/DEBUG(2187): beaed44c 00000000
10-19 10:55:13.671: INFO/DEBUG(2187): beaed450 81506b84 /data/data/com.MyProject/lib/libdatabase_sqlcipher.so
10-19 10:55:13.671: INFO/DEBUG(2187): beaed454 002803d8 [heap]
10-19 10:55:13.671: INFO/DEBUG(2187): beaed458 00281ac8 [heap]
10-19 10:55:13.671: INFO/DEBUG(2187): beaed45c 81503b39 /data/data/com.MyProject/lib/libdatabase_sqlcipher.so

Trying to build for 3.0

I've grabbed the latest git repo - https://github.com/guardianproject/android-database-sqlcipher.git

Then I went in, grabbed some SO's from a 3.0 device, (I'm sure I got the majority of them but might be missing an stlport.so as I couldn't find that...).

ls external/android-3.0/
libcrypto.so libicui18n.so liblog.so libssl.so libutils.so
libcutils.so libicuuc.so libnativehelper.so libstlport.so

But when I go to build from Eclipse, I get a bunch of Cursor errors... along the lines of:

The type BulkCursorToCursorAdaptor must implement the inherited abstract method Cursor.getType(int)

This happens in BulkCursorToCursorAdpator.java, and similar issues about base classes in a few other cursor-related files...

So what am I doing wrong here? I went into the external and I can rebuild the libcrypto.so as well as the libssl.so but that doesn't seem like the right thing to do, it seems
that I need to align my so with the java via the jni but I must be missing a step...

Any thoughts??

loadLibs() will load wrong library after OS update

loadLibs() doesn't do anything to ensure the existing library file that it copied for the previous run is for the correct OS version, this means if i update the OS on my phone, its going to continue to try and load the existing library file which is now for the previous OS version.

Cursor.copyStringToBuffer override is an empty method in 0.0.6

In the 0.0.6 update, the method SQLiteCursor.copyStringToBuffer override is an empty method, rendering it inoperable. Seems like it either needs to be rewritten or the method should be removed so it reverts to the AbstractWindowedCursor implementation.

Database directory not lazy-created

Environment: SQLCipher for Android 2.0.5, as tested on Android 2.2 and 4.0.3 ARM emulators.

Scenario: Install an app, so there is no database directory for the app. Attempt to open a readable database using SQLiteOpenHelper. You crash with:

sqlite3_open_v2("/data/data/com.commonsware.sct/databases/constants.db", &handle, 6, NULL) failed

Or, if you create the directory (e.g., context.getDatabasePath(DATABASE_NAME).getParentFile().mkdirs();), and you attempt to open a readable database, you crash with:

E/AndroidRuntime(1293): Caused by: net.sqlcipher.database.SQLiteException: Can't upgrade read-only database from version 0 to 1: /data/data/com.commonsware.sct/databases/constants.db

Workaround: Don't open a readable database unless the database already exists. Open a writable database instead.

What Should Happen: The database directory should be lazy-created and a database created, even if you said you only needed a readable database.

Sample Code: http://misc.commonsware.com/SQLCipherTest.zip

Q on licensing, deployment and 2.1

Hi,
three questions:

  1. I'm not quite sure but it seems the libs are working with 2.1 too? You do explicitly declare 2.2 and above, but what about 2.1?
  2. I'm having to deploy the 3 libs to the target machine, right?
  3. Do I have to add additional license files to my deployment?

Regards

Unable to access database using raw key data after forcing app to stop

Hi,

I'm trying to use a row key data in order to avoid key derivation (According to the documentation http://sqlcipher.net/sqlcipher-api/#key):

this.myDb = SQLiteDatabase.openOrCreateDatabase(databaseFile, "", null);
this.myDb.rawExecSQL("PRAGMA key = \"x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'\"");
Cursor myCursor = this.myDb.rawQuery(query, params);

When I force the application to stop, accessing the data becomes impossible.

This behaviour does not happen without using SQLCipher. The database is readable even after forcing application to stop.

I'm I doing something wrong ?

Thanks in advance,

sqlcipher_export - "table android_metadata already exists"

Hi,

I'm testing the v2.0.0 RC5 version.

I'm trying to export files from an unencrypted database to an encrypted database.
I'm using sqlcipher_export() function to export it.
Whenever i call sqlcipher_export() the error "table android_metadata already exists" occurs.
The android_metadata table is a default table created automatically. Of course, when I delete android_metadata table in the target database before calling sqlcipher_export() it works. But it would be nice that SqlCipher for Android would handle this.

Or maybe I'm doing somthing wrong?

[source]
SQLiteDatabase database = SQLiteDatabase.openDatabase(unEncryptedDBPath, "", null, SQLiteDatabase.OPEN_READWRITE);
database.execSQL("ATTACH DATABASE '" + encryptedDBPath + "' AS encrypted KEY 'testit';");
database.rawExecSQL("SELECT sqlcipher_export('encrypted');");
database.execSQL("DETACH DATABASE encrypted;");
database.close();
[/source]

regards,
Tom

IllegalStateException: UNKNOWN type 5 running query on Android 3.1

I'm using the beta release, my app runs fine on Android 2.2 & 2.3, but on 3.1 (on a galaxy tab) i see this "IllegalStateException: UNKNOWN type 5" error running a query.

E/AndroidRuntime( 1311): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime( 1311): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime( 1311): at android.os.AsyncTask$3.done(AsyncTask.java:266)
E/AndroidRuntime( 1311): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime( 1311): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime( 1311): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime( 1311): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime( 1311): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
E/AndroidRuntime( 1311): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
E/AndroidRuntime( 1311): at java.lang.Thread.run(Thread.java:1020)
E/AndroidRuntime( 1311): Caused by: java.lang.IllegalStateException: UNKNOWN type 5
E/AndroidRuntime( 1311): at android.database.CursorWindow.getString_native(Native Method)
E/AndroidRuntime( 1311): at android.database.CursorWindow.getString(CursorWindow.java:372)
E/AndroidRuntime( 1311): at info.guardianproject.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:52)
E/AndroidRuntime( 1311): at com.salesforce.crm.db.CursorHelper.getString(CursorHelper.java:40)
E/AndroidRuntime( 1311): at com.salesforce.crm.datastore.SCTab.(SCTab.java:23)
E/AndroidRuntime( 1311): at com.salesforce.crm.datastore.SCFactory.getAllTabs(SCFactory.java:90)
E/AndroidRuntime( 1311): at com.salesforce.crm.HomeScreenMenuFragment$TabLoader.loadInBackground(HomeScreenMenuFragment.java:103)
E/AndroidRuntime( 1311): at com.salesforce.crm.HomeScreenMenuFragment$TabLoader.loadInBackground(HomeScreenMenuFragment.java:88)
E/AndroidRuntime( 1311): at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:243)
E/AndroidRuntime( 1311): at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:52)
E/AndroidRuntime( 1311): at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:41)
E/AndroidRuntime( 1311): at android.os.AsyncTask$2.call(AsyncTask.java:252)
E/AndroidRuntime( 1311): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime( 1311): ... 4 more

Encrypt Preloaded Database. Is this possible?

I am using a preloaded database (stored in the assets folder) of my android project.

I want to encrypt the already defined database. Is this possible please?

Thanks for your time.

ICU dat file on SD card

Add the ability to specify the storage location of the unzipped ICU dat file. Specifically onto a SD card, this is a practical location for older devices that have limited onboard storage.

Converting the existing database to use SQL cipher library

Hi,
I was wondering if there is an easy way to update the app which is already using an unencrypted SQLite database to use the ciphered one? Obviously, one could load each value from the database manually, encrypt it and then write it back and then continue using the library in a standard way, but is there a more straightforward way?

Thanks,
Andrej

What about Android 4.0 support?

It seems that the latest release (0.0.6-FINAL) doesn't work properly on Android 4.0 (at least on emulator).

I've tested the library on notepadbot application, as well as on this sample activity:

public class HelloSQLCipherActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        InitializeSQLCipher();
    }

    private void InitializeSQLCipher() {
        SQLiteDatabase.loadLibs(this);
        File databaseFile = getDatabasePath("demo.db");
        databaseFile.mkdirs();
        databaseFile.delete();
        SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databaseFile, "test123", null);
        database.execSQL("create table t1(a, b)");
        database.execSQL("insert into t1(a, b) values(?, ?)", new Object[]{"one for the money",
                                                                        "two for the show"});
    }
}

And i'm always getting the next exception during the database creation:

12-07 13:02:44.364: E/AndroidRuntime(682): Caused by: info.guardianproject.database.sqlcipher.SQLiteException: not an error
12-07 13:02:44.364: E/AndroidRuntime(682):  at info.guardianproject.database.sqlcipher.SQLiteDatabase.dbopen(Native Method)
12-07 13:02:44.364: E/AndroidRuntime(682):  at info.guardianproject.database.sqlcipher.SQLiteDatabase.<init>(SQLiteDatabase.java:1870)
12-07 13:02:44.364: E/AndroidRuntime(682):  at info.guardianproject.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:863)
12-07 13:02:44.364: E/AndroidRuntime(682):  at info.guardianproject.database.sqlcipher.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:897)
12-07 13:02:44.364: E/AndroidRuntime(682):  at info.guardianproject.database.sqlcipher.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:890)
12-07 13:02:44.364: E/AndroidRuntime(682):  at com.sqlcipher.test.SQLCipherTestActivity.initializeSQLCipher(SQLCipherTestActivity.java:23)
12-07 13:02:44.364: E/AndroidRuntime(682):  at com.sqlcipher.test.SQLCipherTestActivity.onCreate(SQLCipherTestActivity.java:15)
12-07 13:02:44.364: E/AndroidRuntime(682):  at android.app.Activity.performCreate(Activity.java:4465)
12-07 13:02:44.364: E/AndroidRuntime(682):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-07 13:02:44.364: E/AndroidRuntime(682):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-07 13:02:44.364: E/AndroidRuntime(682):  ... 11 more

On all version below 3.2 everything works fine.

Does SQLCipher for android currently supports version 4.0? Have it been tested yet? Is there some workaround?
(Or maybe i'm just doing something wrong?)

build instructions

It'd be great to get the basic steps for doing a build from start to end documented.

No implementation found for native Lnet/sqlcipher/database/SQLiteDatabase;.dbopen (Ljava/lang/String;I)V

06-26 11:38:53.559: W/dalvikvm(22382): No implementation found for native Lnet/sqlcipher/database/SQLiteDatabase;.dbopen (Ljava/lang/String;I)V
06-26 11:38:53.559: D/AndroidRuntime(22382): Shutting down VM
06-26 11:38:53.559: W/dalvikvm(22382): threadid=1: thread exiting with uncaught exception (group=0x40018560)
06-26 11:38:53.569: E/AndroidRuntime(22382): FATAL EXCEPTION: main
06-26 11:38:53.569: E/AndroidRuntime(22382): java.lang.UnsatisfiedLinkError: dbopen
06-26 11:38:53.569: E/AndroidRuntime(22382): at net.sqlcipher.database.SQLiteDatabase.dbopen(Native Method)
06-26 11:38:53.569: E/AndroidRuntime(22382): at net.sqlcipher.database.SQLiteDatabase.(SQLiteDatabase.java:2030)
06-26 11:38:53.569: E/AndroidRuntime(22382): at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:931)
06-26 11:38:53.569: E/AndroidRuntime(22382): at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1010)
06-26 11:38:53.569: E/AndroidRuntime(22382): at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:236)
06-26 11:38:53.569: E/AndroidRuntime(22382): at com.viber.voip.contacts.ViberContactsProvider.onCreate(ViberContactsProvider.java:53)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.content.ContentProvider.attachInfo(ContentProvider.java:798)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.app.ActivityThread.installProvider(ActivityThread.java:3706)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.app.ActivityThread.installContentProviders(ActivityThread.java:3461)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3417)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:977)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.os.Looper.loop(Looper.java:130)
06-26 11:38:53.569: E/AndroidRuntime(22382): at android.app.ActivityThread.main(ActivityThread.java:3835)
06-26 11:38:53.569: E/AndroidRuntime(22382): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 11:38:53.569: E/AndroidRuntime(22382): at java.lang.reflect.Method.invoke(Method.java:507)
06-26 11:38:53.569: E/AndroidRuntime(22382): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
06-26 11:38:53.569: E/AndroidRuntime(22382): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
06-26 11:38:53.569: E/AndroidRuntime(22382): at dalvik.system.NativeStart.main(Native Method)
06-26 11:38:53.589: W/ActivityManager(224): Force finishing activity com.viber.voip/.Encrypt
06-26 11:38:54.089: W/ActivityManager(224): Activity pause timeout for HistoryRecord{4057b378 com.viber.voip/.Encrypt}

Ambiguous behaviour of the database when the database is deleted and recreated

I use a SqliteOpenHelper to create a database (say "MyDB"). During a particular condition I have to clear the database. So I use context.deleteDatabase("MyDB") to remove the db and recreate it once again. But after this the database starts behaving erratically. For instance while fetching entries (using the same query) from the DB I get correct results during the first 2 times but 3rd time onwards I donot get any data.

On the other hand If I somehow manage to kill my app (using Task killer) and then repeat the above process everything works fine.

I have cross-checked my code a number of times and haven't found couldnot find any bug.

Documentation Issue: Link to Downloads

The first paragraph of the README links to the old repo location for the downloads, rather than to this repo's downloads area. Clicking on the erroneous link takes you to a "there are no downloads" page.

use cipher for existing database in other languages

Hi
I have a DB and add it to my project(in asset). my db has some character in Persian language. when I want create database from and open it, eclipse show followed error:(in logcat)
01-08 14:38:47.156: ERROR/Database(23739): SELECT locale FROM android_metadata failed
01-08 14:38:47.235: ERROR/Database(23739): Failed to setLocale() when constructing, closing the database
01-08 14:38:47.235: ERROR/Database(23739): info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or is not a database
01-08 14:38:47.235: ERROR/Database(23739): at info.guardianproject.database.sqlcipher.SQLiteDatabase.native_setLocale(Native Method)
.
.
.01-08 14:38:48.795: ERROR/Database(23739): CREATE TABLE android_metadata failed
01-08 14:38:48.836: ERROR/Database(23739): Failed to setLocale() when constructing, closing the database
01-08 14:38:48.836: ERROR/Database(23739): info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or is not a database
01-08 14:38:48.836: ERROR/Database(23739): at info.guardianproject.database.sqlcipher.SQLiteDatabase.native_setLocale(Native Method)
.
.
.
01-08 14:38:48.865: ERROR/SQLiteOpenHelper(23739): Couldn't open nutrition.db.mp3 for writing (will try read-only):
01-08 14:38:48.865: ERROR/SQLiteOpenHelper(23739): info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or is not a database
01-08 14:38:48.865: ERROR/SQLiteOpenHelper(23739): at info.guardianproject.database.sqlcipher.SQLiteDatabase.native_setLocale(Native Method)
.
,
.
01-08 14:38:50.716: ERROR/AndroidRuntime(23739): FATAL EXCEPTION: main
01-08 14:38:50.716: ERROR/AndroidRuntime(23739): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tebyan.diet/com.tebyan.diet.StartTabBar}: info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or is not a database
01-08 14:38:50.716: ERROR/AndroidRuntime(23739): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)

I think cipher can not make android_metadata table, but why?
I add this table manualy in DBMS but does not work!
thanks,
yarand

Building android-database-sqlcipher

When I try to build this using ndk I get the following error, any ideas?

$ ndk-build
Compile++ thumb : database_sqlcipher <= CursorWindow.cpp
In file included from D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:20:
D:/cygwin/home/userX/sqlcipher/jni/include/utils/Log.h:31:24: error: cutils/log.h: No such file or directory
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:21:35: error: binder/MemoryHeapBase.h: No such file or directory
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:22:31: error: binder/MemoryBase.h: No such file or directory
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:29:21: error: JNIHelp.h: No such file or directory
In file included from D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:31:
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:29:28: error: binder/IMemory.h: No such file or directory
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:30:27: error: utils/RefBase.h: No such file or directory
In file included from D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:31:
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:110: error: expected unqualified-id before '<' token
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:110: error: expected ')' before '<' token
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:110: error: expected ';' before '<' token
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:114: error: ISO C++ forbids declaration of 'sp' with no type
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:114: error: invalid use of '::'
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:114: error: expected ';' before '<' token
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:116: error: expected ';' before 'size_t'
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:198: error: ISO C++ forbids declaration of 'sp' with no type
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:198: error: invalid use of '::'
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:198: error: expected ';' before '<' token
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h: In member function 'bool android::CursorWindow::setNumColumns(uint32_t)':
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.h:129: error: 'LOGE' was not declared in this scope
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp: At global scope:
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:41: error: expected unqualified-id before '<' token
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:41: error: expected ')' before '<' token
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:41: error: expected initializer before '<' token
D:/cygwin/home/userX/sqlcipher/jni/CursorWindow.cpp:413: error: expected '}' at end of input
make: *** [/home/userX/sqlcipher/obj/local/armeabi/objs/database_sqlcipher/CursorWindow.o] Error 1

Couldn't load stlport_shared

Thank you for providing an open source project for protecting the database, as security is a very important feature in my app. I added the jars and so files as mentioned in the installation guide and made the code changes, but I am getting the following error in loadlibs. Can you please help me with this issue.

11-17 12:18:41.827: ERROR/AndroidRuntime(31107): java.lang.UnsatisfiedLinkError: Couldn't load stlport_shared: findLibrary returned null
11-17 12:18:41.827: ERROR/AndroidRuntime(31107): at java.lang.Runtime.loadLibrary(Runtime.java:429)
11-17 12:18:41.827: ERROR/AndroidRuntime(31107): at java.lang.System.loadLibrary(System.java:554)
11-17 12:18:41.827: ERROR/AndroidRuntime(31107): at info.guardianproject.database.sqlcipher.SQLiteDatabase.loadLibs(SQLiteDatabase.java:104)

Why is it not able to load stlport_shared, should i do any specific compilation for the so files?

Android internal db path

Hi,

I am trying to create a database with path as default database path in android, with code as below. I get unable to open database file exception. If i give sdcard path it works perfectly, however i do not want my db available in sdcard. Is there a way to make this work internally? (I do not use dbhelper)

Code:

String dbPath = context.getDatabasePath(DATABASE_NAME).toString()
sqLiteDatabase = SQLiteDatabase.openOrCreateDatabase(dbPath, "password", null);

Exception:

info.guardianproject.database.sqlcipher.SQLiteException: unable to open database file

Thanks & Regards,
Swarna

FTS3/4 MATCH not supported?

In the sqlcipher documentation I read, that one should favor FTS over LIKE for performance. I wonder why I get the following error. I reduced my real world example to this simplified case:

Schema:
CREATE VIRTUAL TABLE sites USING fts4(domain, url, title, meta_keys, body)
CREATE TABLE keywords (keyword TEXT)

Query:
SELECT keyword FROM keywords INNER JOIN sites ON sites.title MATCH keywords.keyword

I get a info.guardianproject.database.sqlcipher.SQLiteException: "SQL logic error or missing database".

info.guardianproject.database.sqlcipher.SQLiteQuery.native_fill_window(Native Method)
info.guardianproject.database.sqlcipher.SQLiteQuery.fillWindow(SQLiteQuery.java:73)
info.guardianproject.database.sqlcipher.SQLiteCursor.fillWindow(SQLiteCursor.java:290)
info.guardianproject.database.sqlcipher.SQLiteCursor.getCount(SQLiteCursor.java:271)
android.database.CursorWrapper.getCount(CursorWrapper.java:51)

java.lang.UnsatisfiedLinkError: dbopen

06-24 16:47:03.349: E/AndroidRuntime(6500): FATAL EXCEPTION: main
06-24 16:47:03.349: E/AndroidRuntime(6500): java.lang.UnsatisfiedLinkError: dbopen
06-24 16:47:03.349: E/AndroidRuntime(6500): at net.sqlcipher.database.SQLiteDatabase.dbopen(Native Method)
06-24 16:47:03.349: E/AndroidRuntime(6500): at net.sqlcipher.database.SQLiteDatabase.(SQLiteDatabase.java:2030)
06-24 16:47:03.349: E/AndroidRuntime(6500): at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:931)
06-24 16:47:03.349: E/AndroidRuntime(6500): at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1010)
06-24 16:47:03.349: E/AndroidRuntime(6500): at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:236)
06-24 16:47:03.349: E/AndroidRuntime(6500): at dbxyzptlk.l.c.a(Unknown Source)
06-24 16:47:03.349: E/AndroidRuntime(6500): at dbxyzptlk.l.c.(Unknown Source)
06-24 16:47:03.349: E/AndroidRuntime(6500): at com.dropbox.android.util.aE.b(Unknown Source)
06-24 16:47:03.349: E/AndroidRuntime(6500): at com.dropbox.android.util.aE.a(Unknown Source)
06-24 16:47:03.349: E/AndroidRuntime(6500): at com.dropbox.android.DropboxApplication.onCreate(Unknown Source)
06-24 16:47:03.349: E/AndroidRuntime(6500): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
06-24 16:47:03.349: E/AndroidRuntime(6500): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3424)
06-24 16:47:03.349: E/AndroidRuntime(6500): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
06-24 16:47:03.349: E/AndroidRuntime(6500): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:977)
06-24 16:47:03.349: E/AndroidRuntime(6500): at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 16:47:03.349: E/AndroidRuntime(6500): at android.os.Looper.loop(Looper.java:130)
06-24 16:47:03.349: E/AndroidRuntime(6500): at android.app.ActivityThread.main(ActivityThread.java:3835)
06-24 16:47:03.349: E/AndroidRuntime(6500): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 16:47:03.349: E/AndroidRuntime(6500): at java.lang.reflect.Method.invoke(Method.java:507)
06-24 16:47:03.349: E/AndroidRuntime(6500): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
06-24 16:47:03.349: E/AndroidRuntime(6500): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
06-24 16:47:03.349: E/AndroidRuntime(6500): at dalvik.system.NativeStart.main(Native Method)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.