Sqlite encryption for Android - android

I have an Android app that has been already developed using SQLite.
The DB is quite large (over 100 Megs) so it can be deployed only on the SD card.
The data inside the DB is sensitive so for this reason we need to encrypt the DB.
The default SQLite binary on the phone does not allow encryption or to add a plug in (extensions).
I manage to compile the SQLite using NDK with the encryption extension (I am calling this SQLiteS - from secure) but I still need to figure out how to copy the Sqlite API and bind it to the new SQLiteS binary.
The idea is to not change the already developed code using the SQLite default API excepting the package name.
Any idea of how can I accomplish this ?

Tryp getting a native jdbcsqlite driver onto Android.
which makes sqlite3_* calls(JNI).
Use the aapt tool to link the library(sqliteS) into the .apk file.
Also, you can change the sqlite3_* names(in SQLiteS.so you built) so that it doesnt refer to sqlite.so file provided by android.
Let me know the solution.

I know this is not an answer for your question, but you could try the (free, open source) H2 database. It supports data file encryption as well. There are some disadvantages however, for example some operations are quite a bit slower. You would need to use the JDBC API because the SQLite / Android database API is not yet supported. Disclaimer: I'm one of the H2 committers.

Use sqlCipher. SQLCipher is an open source extension to SQLite that provides transparent 256-bit AES encryption of database files.
See http://sqlcipher.net/

Related

Android SQLite app, preparing for production

I have an Android app where I use a SQLIte DataBase. I am using the app and the DB is already big. Now I want to give this app with its DB to my coworkers. Where and How to put the DB for release? I have the DB in my phone but I need it in assets folder. I was trying but it doesn't work. I tried to copy the DB directly however I read that Android compress files in that folder. Please, any solution, thank you in advance.
http://blog.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
Visit this link. It contains the easiest and well described answer for your question.
You can use emulator Like GenyMotion and any other emulator. Run your app on emulator then just go to Android Studio->Tools->Android Device Monitor Then select the emulator and in the file Explorer you can find your db file . and then export from the device and export to your desktop. here you can give it to any one.
You can use your own SQLite database by adding it to assets folder. The best way is to use Android SQLiteAssetHelper. Better than reinventing the wheel.
Here the excerpts from its readme:
An Android helper class to manage database creation and version
management using an application's raw asset files.
This class provides developers with a simple way to ship their Android
app with an existing SQLite database (which may be pre-populated with
data) and to manage its initial creation and any upgrades required
with subsequent version releases.
It is implemented as an extension to SQLiteOpenHelper, providing an
efficient way for ContentProvider implementations to defer opening and
upgrading the database until first use.
Rather than implementing the onCreate() and onUpgrade() methods to
execute a bunch of SQL statements, developers simply include
appropriately named file assets in their project's assets directory.
These will include the initial SQLite database file for creation and
optionally any SQL upgrade scripts.

Android: SQLite encryption without external libraries

I am looking for a solution to perform encryption/decryption of a SQLite databse in a Android app without using any external libraries etc...
I read a lot about SQLCipher (https://guardianproject.info/code/sqlcipher/),
the SQLite extension that provides transparent 256-bit AES encryption
of database files
but it's not what I'm looking for...
Is it possible, for example, to compile the SQLite extension of my android project (which is in C) including the encryption module (This one: https://www.sqlite.org/see/doc/trunk/www/index.wiki from the SQLite org) ?
After I should be able to use it from my jni folder.
I actually don't know if it's the correct way or even if it's possible...
If you have any solutions, suggestions...

RDF databases on Android

I'm working on a project on mobile RDF databases for Android. Therefore I'm looking for open source databases to include in my Android project. However, it's difficult for me to find mobile versions of existing RDF databases.
What I've found so far:
Jena TDB database
Oracle Berkeley database
Unfortunately I haven't found mobile versions of Sesame, Virtuoso, AllegroGraph, etc.
Does anyone know some other RDF databases for Android?
I'm not an Android developer, so perhaps I'm overlooking something, but Sesame comes as a collection of maven modules, each a separate Java jar file. You can pick and choose the jar files you need and as far as I'm aware, you should be able to use them on Android straightaway. I don't think there's any need for a separate "mobile version", is there?
I am taking a look to Triple Place.
a light weight and flexible Triple Store for Android. It uses a
indexing structure similar to the one in Hexastore. TriplePlace uses
TokyoCabinet as persistent storage system.
You can find a brief presentation of its features here.
You can use SQLite to store RDF data and make queries for the triples, but SPARQL couldn't be done. Here is a good reference:
http://infolab.stanford.edu/~melnik/rdf/db.html
I would also take a look at 4store.

Encrypt android database without using 3rd party jars or field by field encryption

I have been working on a task assigned by my senior where i need to encrypt my application database but not allowed to do any of the following things:
no use of 3rd party jar files (guardian project or something)
cannot encrypt field-by-field encryption
I just have to encrypt and decrypt my database file through my application but excluding above conditions.
If anybody has done this, please lemme know anything you can tel me.
And i would like to tell you as per my senior it is possible to encrypt database, so there is no question whether it is possible or not without using 3rd party jar files or something.
I just have to encrypt and decrypt my database file through my application but excluding above conditions.
This is not possible given your restrictions, unless you rebuild the firmware with an encryption-enabled copy of SQLite (and I do not know if that is possible either).
Well you could use the android Cipher class. This link might help you
http://www.helloandroid.com/tutorials/encrypting-your-data

Are SQLite's s3db files portable from Windows to iOS / Android platforms?

I would like to use a Windows-based SQLite Administrator to work on my SQLite database. Is the DB file (s3db) portable to mobile platforms like iOS and Android?
A SQLite database file is just that, a file so it should work on any file system/OS regardless of where it was created. The one exception to that would be something like encoding, but the beauty of SQLite is that it's actually just an abstraction on a flat file that allows you to preform most of the relational db functionality. Also, because it's a standardized format, any client should work to read it as well (assuming both the creator and the reader conform to the specification).
SQLite db files should be OS independant. Even file system independant. The files don't have encoding like UTF-8 or ISO-8859-1 (or whatever the order of the numbers is, I always forget) because they're binary.
Have you tried?
Maybe the SQLite client matters. Maybe some clients leave signatures or something? The OS shouldn't matter.
Absolutely cross platform. From the SQLite page:
Stable Cross-Platform Database File
The SQLite file format is
cross-platform. A database file
written on one machine can be copied
to and used on a different machine
with a different architecture.
Big-endian or little-endian, 32-bit or
64-bit does not matter. All machines
use the same file format. Furthermore,
the developers have pledged to keep
the file format stable and backwards
compatible, so newer versions of
SQLite can read and write older
database files. Most other SQL
database engines require you to dump
and restore the database when moving
from one platform to another and often
when upgrading to a newer version of
the software.
http://www.sqlite.org/different.html#onefile

Categories

Resources