calling sqlite3 in Native code with NDK

3,532 views
Skip to first unread message

Abhi

unread,
Oct 4, 2011, 4:54:34 PM10/4/11
to android-ndk
Hi Guys,

I am working on porting some native code (c++) to my Android
application. The Native C++ code is making some sqlite3 calls using
the sqlite3.dll. I want to be able to use either a .so version of
sqlite3 or compile sqlite3.c as part of the native code using NDK. I
don't know which is easier to do.

I looked online and found a couple of different answers but none of
them were well documented and left me confused. If anyone knows of any
online resource that has an answer to my question, I would really
appreciate if you could point me to it.

Thanks,

AB

Krystian Bigaj

unread,
Oct 5, 2011, 2:54:25 AM10/5/11
to android-ndk
The easiest way is just include sqlite3.c/h (amalgamation) in your
project as a normal source file, you don't need any additional .so/.a
It will work just fine.

If you would like to access APK 'assets' directory by SQLite (only
Android 2.3+, and DB as read-only) you can do it by http://code.google.com/p/sqlite-ndk/
There is also example which includes sqlite3.c/h in project.

--
Best regards
Krystian Bigaj

Abhi

unread,
Oct 5, 2011, 3:49:35 PM10/5/11
to android-ndk
Thanks a lot. That worked!

On Oct 5, 2:54 am, Krystian Bigaj <krystian.bi...@gmail.com> wrote:
> The easiest way is just include sqlite3.c/h (amalgamation) in your
> project as a normal source file, you don't need any additional .so/.a
> It will work just fine.
>
> If you would like to access APK 'assets' directory by SQLite (only
> Android 2.3+, and DB as read-only) you can do it byhttp://code.google.com/p/sqlite-ndk/

kapil sukhyani

unread,
Apr 23, 2015, 8:33:23 PM4/23/15
to andro...@googlegroups.com, krystia...@gmail.com
Would there be any problem if database is not in assets and I try to write to it?

Krystian Bigaj

unread,
Apr 25, 2015, 8:58:51 AM4/25/15
to andro...@googlegroups.com, krystia...@gmail.com
If the database file is on a SD/internal card, then you can simply access (read/write) it by a SQLite (you don't need a sqlite-ndk).
Reply all
Reply to author
Forward
0 new messages