我有一个安卓应用要链接数据库,在linux里面用GCC成功了,现在我想在安卓(ARM处理器)里面链接同样的数据库,但是NDK只能支持JNI。我现在想建立一个共享的数据库不用JNI连接。怎么实现?
my stuture is
----->JNI
---->myfile.c(jni c code)
----->android.mk(here i call my two shared lib)
folder1
--->include
----src
---->lib(here i will get my shared lib)
folder 2
----->include
----->src
----->lib(here i will get my 2nd shared lib)
需要单独创建共享数据库并且能调用。不使用JNI。能实现吗?
可以,需要为数据库创建Android.mk
和Application.mk
文件。可以用已有的makefile
创建Android.mk
。
在Application.mk
文件中:
APP_OPTIM:= release
APP_PLATFORM:= android-7
APP_STL:= gnustl_static
APP_CPPFLAGS+= -frtti
APP_CPPFLAGS+= -fexceptions
APP_CPPFLAGS+= -DANDROID
APP_ABI:= armeabi-v7a
APP_MODULES:= <put-the-name-of-your-library-here>
然后编译数据库的时候用ndk-build
。
可以自己写lib api,编译成可执行程序,或者动态库,供jni和java调用