Skip to content

Commit 7d48b1f

Browse files
Update README to include API usage and ref. library version
1 parent 6c132c9 commit 7d48b1f

File tree

3 files changed

+77
-19
lines changed

3 files changed

+77
-19
lines changed

README.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
SQLCipher for Android provides a library replacement for `android.database.sqlite` on the Android platform for use on [SQLCipher](https://github.com/sqlcipher/sqlcipher) databases. This library is based on the upstream [Android Bindings](https://www.sqlite.org/android/doc/trunk/www/index.wiki) project and aims to be a long-term replacement for the original [SQLCipher for Android](https://github.com/sqlcipher/android-database-sqlcipher) library.
44

5-
***N.B.*** This library is currently distributed in source-only format at this time, and requires [other external dependencies](#external-dependencies) to build. Community edition AAR artifacts will be distributed eventually.
6-
75
### Compatibility
86

97
SQLCipher for Android supports Android API 21 and up on `armeabi-v7a`, `x86`, `x86_64`, and `arm64_v8a` architectures.
@@ -17,19 +15,19 @@ We welcome contributions, to contribute to SQLCipher for Android, a [contributor
1715

1816
Add a local reference to the local library and dependency:
1917

20-
```
21-
implementation files('libs/sqlcipher-android-4.5.2-release.aar')
18+
```groovy
19+
implementation files('libs/sqlcipher-android-4.5.5-release.aar')
2220
implementation 'androidx.sqlite:sqlite:2.2.0'
2321
```
2422

2523
or source a Community edition build from Maven Central:
2624

27-
```
28-
implementation 'net.zetetic:sqlcipher-android:4.5.2@aar'
25+
```groovy
26+
implementation 'net.zetetic:sqlcipher-android:4.5.5@aar'
2927
implementation 'androidx.sqlite:sqlite:2.2.0'
3028
```
3129

32-
```
30+
```java
3331
import net.zetetic.database.sqlcipher.SQLiteDatabase;
3432

3533
System.loadLibrary("sqlcipher");
@@ -40,20 +38,51 @@ SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databaseFile, pass
4038

4139
To perform operations on the database instance immediately before or after the keying operation is performed, provide a `SQLiteDatabaseHook` instance when creating your database connection:
4240

43-
```
41+
```java
4442
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
4543
public void preKey(SQLiteConnection connection) { }
4644
public void postKey(SQLiteConnection connection) { }
4745
};
4846
```
4947

48+
### API Usage
49+
50+
There are two main options for using SQLCipher for Android within an Application:
51+
52+
1. [Using the SQLCipher for Android classes](#sqlcipher-for-android-classes)
53+
2. [Using SQLCipher for Android in conjunction with the Android Room API](#sqlcipher-for-android-room-integration)
54+
55+
In both cases, prior to using any portion of the SQLCipher for Android library, the native SQLCipher core library must be loaded into the running application process. The SQLCipher core library is bundled within the AAR of SQLCipher for Android, however, the developer must load this library explicitly. An example below:
56+
57+
```java
58+
System.loadLibrary("sqlcipher");
59+
```
60+
61+
#### SQLCipher for Android classes
62+
63+
SQLCipher for Android provides two classes for opening and access database files. The `SQLiteDatabase` provides static methods for opening/creating database files and general data access.
64+
Additionally, applications may choose to subclass the `SQLiteOpenHelper` class which provides mechanisms for performing database migrations, as well as general data access.
65+
66+
#### SQLCipher for Android Room Integration
67+
68+
SQLCipher for Android may also integrate with the Room API via the `SupportOpenHelperFactory`, an example is given below:
69+
70+
```java
71+
System.loadLibrary("sqlcipher");
72+
String password = "Password1!";
73+
File databaseFile = context.getDatabasePath("demo.db");
74+
SupportOpenHelperFactory factory = new SupportOpenHelperFactory("password.getBytes(StandardCharsets.UTF_8));
75+
db = Room.databaseBuilder(context, AppDatabase.class, databaseFile.getAbsolutePath())
76+
.openHelperFactory(factory).build();
77+
```
78+
5079
### Building
5180
5281
## Android NDK
5382
5483
Currently, SQLCipher for Android uses NDK version "25.2.9519653".
5584
56-
## <a name="external-dependencies" />External dependencies:
85+
## External dependencies
5786
5887
This repository is not batteries-included. Specifically, you will need to build `libcrypto.a`, the static library from OpenSSL using the NDK for the [supported platforms](#compatibility), and bundle the top-level `include` folder from OpenSSL. Additionally, you will need to build a SQLCipher amalgamation. These files will need to be placed in the following locations:
5988

README.md.template

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
SQLCipher for Android provides a library replacement for `android.database.sqlite` on the Android platform for use on [SQLCipher](https://github.com/sqlcipher/sqlcipher) databases. This library is based on the upstream [Android Bindings](https://www.sqlite.org/android/doc/trunk/www/index.wiki) project and aims to be a long-term replacement for the original [SQLCipher for Android](https://github.com/sqlcipher/android-database-sqlcipher) library.
44

5-
***N.B.*** This library is currently distributed in source-only format at this time, and requires [other external dependencies](#external-dependencies) to build. Community edition AAR artifacts will be distributed eventually.
6-
75
### Compatibility
86

97
SQLCipher for Android supports Android API <%=minSdkVersion%> and up on `armeabi-v7a`, `x86`, `x86_64`, and `arm64_v8a` architectures.
@@ -17,19 +15,19 @@ We welcome contributions, to contribute to SQLCipher for Android, a [contributor
1715

1816
Add a local reference to the local library and dependency:
1917

20-
```
21-
implementation files('libs/sqlcipher-android-4.5.2-release.aar')
18+
```groovy
19+
implementation files('libs/sqlcipher-android-<%=libraryVersion%>-release.aar')
2220
implementation 'androidx.sqlite:sqlite:<%=androidXSQLiteVersion%>'
2321
```
2422

2523
or source a Community edition build from Maven Central:
2624

27-
```
28-
implementation 'net.zetetic:sqlcipher-android:4.5.2@aar'
25+
```groovy
26+
implementation 'net.zetetic:sqlcipher-android:<%=libraryVersion%>@aar'
2927
implementation 'androidx.sqlite:sqlite:<%=androidXSQLiteVersion%>'
3028
```
3129

32-
```
30+
```java
3331
import net.zetetic.database.sqlcipher.SQLiteDatabase;
3432

3533
System.loadLibrary("sqlcipher");
@@ -40,20 +38,51 @@ SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databaseFile, pass
4038

4139
To perform operations on the database instance immediately before or after the keying operation is performed, provide a `SQLiteDatabaseHook` instance when creating your database connection:
4240

43-
```
41+
```java
4442
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
4543
public void preKey(SQLiteConnection connection) { }
4644
public void postKey(SQLiteConnection connection) { }
4745
};
4846
```
4947

48+
### API Usage
49+
50+
There are two main options for using SQLCipher for Android within an Application:
51+
52+
1. [Using the SQLCipher for Android classes](#sqlcipher-for-android-classes)
53+
2. [Using SQLCipher for Android in conjunction with the Android Room API](#sqlcipher-for-android-room-integration)
54+
55+
In both cases, prior to using any portion of the SQLCipher for Android library, the native SQLCipher core library must be loaded into the running application process. The SQLCipher core library is bundled within the AAR of SQLCipher for Android, however, the developer must load this library explicitly. An example below:
56+
57+
```java
58+
System.loadLibrary("sqlcipher");
59+
```
60+
61+
#### SQLCipher for Android classes
62+
63+
SQLCipher for Android provides two classes for opening and access database files. The `SQLiteDatabase` provides static methods for opening/creating database files and general data access.
64+
Additionally, applications may choose to subclass the `SQLiteOpenHelper` class which provides mechanisms for performing database migrations, as well as general data access.
65+
66+
#### SQLCipher for Android Room Integration
67+
68+
SQLCipher for Android may also integrate with the Room API via the `SupportOpenHelperFactory`, an example is given below:
69+
70+
```java
71+
System.loadLibrary("sqlcipher");
72+
String password = "Password1!";
73+
File databaseFile = context.getDatabasePath("demo.db");
74+
SupportOpenHelperFactory factory = new SupportOpenHelperFactory("password.getBytes(StandardCharsets.UTF_8));
75+
db = Room.databaseBuilder(context, AppDatabase.class, databaseFile.getAbsolutePath())
76+
.openHelperFactory(factory).build();
77+
```
78+
5079
### Building
5180

5281
## Android NDK
5382

5483
Currently, SQLCipher for Android uses NDK version "<%=androidNdkVersion%>".
5584

56-
## <a name="external-dependencies" />External dependencies:
85+
## External dependencies
5786

5887
This repository is not batteries-included. Specifically, you will need to build `libcrypto.a`, the static library from OpenSSL using the NDK for the [supported platforms](#compatibility), and bundle the top-level `include` folder from OpenSSL. Additionally, you will need to build a SQLCipher amalgamation. These files will need to be placed in the following locations:
5988

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ project.ext {
2828
if(project.hasProperty('sqlcipherAndroidVersion') && "${sqlcipherAndroidVersion}") {
2929
libraryVersion = "${sqlcipherAndroidVersion}"
3030
} else {
31-
libraryVersion = "4.5.3"
31+
libraryVersion = "4.5.5"
3232
}
3333
minSdkVersion = 21
3434
androidXSQLiteVersion = "2.2.0"

0 commit comments

Comments
 (0)