SQLite with Android NDK

后端 未结 4 2108
抹茶落季
抹茶落季 2020-12-01 08:30

Is it somehow possible to use SQLite with C++ on an Android phone? I haven\'t found any documentation around how this could be possible.

4条回答
  •  既然无缘
    2020-12-01 08:48

    Disclaimer: i have only used this method for standalone executables, not libraries that implement JNI functions. It may work for a .so or not. Also, i'm working with a custom Android device not a phone.

    You can use the built in SQLite via NDK but it's more of a hack than something supported. You need to nick sqlite3.h and libsqlite.so from an android source distribution and compile using them. Put sqlite3.h in your application source directory and you need to put the .so somewhere under the out/yourapp directory or build/platform/android-x/arch-arm/usr/lib for the linking step to finish. I have it in both places but i'm not sure which one is really needed.

    You will end up linking to the libsqlite.so you provided but the binary will run fine using the system libsqlite.so on a target device.

提交回复
热议问题