Android assets cannot be accessed directly, neither in Java nor in native code. They are not files on the filesystem but are compressed data inside of your APK.
Here's what you should do:
Android has built-in support for SQLite. Rather than including a database file in your app, let your app create the database in Java, using what's provided in the android.database package. This will create a regular SQLite database file (usually found in
data/data/your.app.package/databases/
) accessible in native code.If that's not feasible and you really want to go with the asset approach, use
AssetManager
in Java to extract the asset and create a regular file accessible in native code, i.e. effectively creating a copy of what's contained in the asset.
Perhaps the best thing in the long run would be to restructure your app such that you do not need to handle a database in native code at all. Instead, open and query the database in Java (using one of the two solutions above) and pass only the necessary data to native code. Typically, the more application logic you can shift to Java, the better.