Help us understand the problem. What is going on with this article?

AndroidStudioでSQLiteを暗号化するSQLCipherを使う

More than 5 years have passed since last update.

AndroidStudioでSQLiteを暗号化する、SQLCipherを取り込むのに苦労したので備忘録的に。

まずは、SQLCipherの下記ページからAndroid用のライブラリ一式をダウンロード。
http://sqlcipher.net/open-source/
https://s3.amazonaws.com/sqlcipher/SQLCipher+for+Android+v3.0.2.zip

ダウンロードしたライブラリを解凍すると、下記のような構成になっている。
SQLCipher
|- assets/
|- libs/
|- READEME
|- SQLCIPHER_LICENSE

次に、プロジェクト上のapp配下に、解凍したassetsとlibsをコピー
スクリーンショット 2014-02-21 01.56.27.png

app/build.gradleを更新。

build.gradle
android {
    compileSdkVersion 18
    buildToolsVersion "19.0.1"

    ....
    sourceSets {
        main {
            assets {
                srcDirs = ['assets']
            }
        }
    }
}

dependencies {
    ....
    compile files('libs/commons-codec.jar')
    compile files('libs/guava-r09.jar')
    compile files('libs/sqlcipher.jar')
    compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}

// for native modules
task copyNativeLibs(type: Copy) {
    from('libs') { include '**/*.so' }
    into new File(buildDir, 'native-libs')
}
tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
    pkgTask.jniFolders = new HashSet<File>()
    pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
}
clean.dependsOn 'cleanCopyNativeLibs'

ここまでできれば後は、「Run 'app'」するだけ。

monotas
mono + mono = ∞ ITを活用したモノづくりで、生産性の向上に貢献します
https://www.monotas.net/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした