Skip to content

Commit 9a99513

Browse files
Generate README.md from template file to avoid stale version numbers
1 parent 57bb6db commit 9a99513

File tree

4 files changed

+86
-2
lines changed

4 files changed

+86
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ We welcome contributions, to contribute to SQLCipher for Android, a [contributor
1313

1414
### Application Integration
1515

16+
When available on Maven Central, add a reference to the library and dependency:
17+
18+
```
19+
implementation "net.zetetic:sqlcipher-android:4.4.3"
20+
implementation "androidx.sqlite:sqlite:2.1.0"
21+
```
1622

1723
```
1824
import net.zetetic.database.sqlcipher.SQLiteDatabase;

README.md.template

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SQLCipher for Android
2+
3+
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 project and aims to be a long-term replacement for the original [SQLCipher for Android](https://github.com/sqlcipher/android-database-sqlcipher) library.
4+
5+
### Compatibility
6+
7+
SQLCipher for Android supports Android API 16 and up on `armeabi-v7a`, `x86`, `x86_64`, and `arm64_v8a` architectures.
8+
9+
### Contributions
10+
11+
We welcome contributions, to contribute to SQLCipher for Android, a [contributor agreement](https://www.zetetic.net/contributions/) needs to be submitted. All submissions should be based on the `master` branch.
12+
13+
14+
### Application Integration
15+
16+
When available on Maven Central, add a reference to the library and dependency:
17+
18+
```
19+
implementation "net.zetetic:sqlcipher-android:<%=libraryVersion%>"
20+
implementation "androidx.sqlite:sqlite:<%=androidXSQLiteVersion%>"
21+
```
22+
23+
```
24+
import net.zetetic.database.sqlcipher.SQLiteDatabase;
25+
26+
System.loadLibrary("sqlcipher");
27+
SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databaseFile, password, null, null, null);
28+
```
29+
30+
### Pre/Post Key Operations
31+
32+
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:
33+
34+
```
35+
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
36+
public void preKey(SQLiteConnection connection) { }
37+
public void postKey(SQLiteConnection connection) { }
38+
};
39+
```
40+
41+
### Building
42+
43+
This repository is not batteries-included. Specificially, 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:
44+
45+
```
46+
<project-root>/sqlcipher/src/main/jni/sqlcipher/android-libs/armeabi-v7a/libcrypto.a
47+
<project-root>/sqlcipher/src/main/jni/sqlcipher/android-libs/x86/libcrypto.a
48+
<project-root>/sqlcipher/src/main/jni/sqlcipher/android-libs/x86_64/libcrypto.a
49+
<project-root>/sqlcipher/src/main/jni/sqlcipher/android-libs/arm64_v8a/libcrypto.a
50+
<project-root>/sqlcipher/src/main/jni/sqlcipher/android-libs/include/
51+
<project-root>/sqlcipher/src/main/jni/sqlcipher/sqlite3.c
52+
<project-root>/sqlcipher/src/main/jni/sqlcipher/sqlite3.h
53+
```
54+
55+
To build the AAR package, either build directly within Android Studio, or from the command line:
56+
57+
```
58+
./gradlew assembleRelease
59+
```
60+

build.gradle

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1+
import groovy.text.SimpleTemplateEngine
2+
23
buildscript {
34
repositories {
45
jcenter()
@@ -24,6 +25,7 @@ allprojects {
2425

2526
project.ext {
2627
libraryVersion = "4.4.3"
28+
androidXSQLiteVersion = "2.1.0"
2729
mavenLocalRepositoryPrefix = "file://"
2830
if(project.hasProperty('publishLocal') && publishLocal.toBoolean()){
2931
mavenSnapshotRepositoryUrl = "outputs/snapshot"
@@ -68,3 +70,19 @@ nexusPublishing {
6870
}
6971
}
7072
}
73+
74+
task generateReadMe {
75+
def readme = new File("README.md")
76+
def engine = new SimpleTemplateEngine()
77+
def reader = new FileReader("README.md.template")
78+
def binding = [
79+
libraryVersion: project.ext.libraryVersion,
80+
androidXSQLiteVersion: project.ext.androidXSQLiteVersion
81+
]
82+
def template = engine.createTemplate(reader).make(binding)
83+
readme.write(template.toString())
84+
}
85+
86+
project.afterEvaluate {
87+
build.dependsOn generateReadMe
88+
}

sqlcipher/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ dependencies {
5151
implementation fileTree(include: ['*.jar'], dir: 'libs')
5252

5353
// Needed for the Support API interfaces
54-
implementation 'androidx.sqlite:sqlite:2.1.0'
54+
implementation "androidx.sqlite:sqlite:${rootProject.ext.androidXSQLiteVersion}"
5555

5656
// Needed for the Support API in tests
5757
androidTestImplementation 'androidx.room:room-common:2.3.0'

0 commit comments

Comments
 (0)