-1

I am using http://www.sqlite.org/c3ref/open.html as a reference for using the sqlite c for opening the db

i m calling like this

    package com.example.offline;

    public class NativeLib {

    static {
    System.loadLibrary("sqlite3");
    }

    public native int sqlite3_open(String filename,Object sqlite3);

    }

As documentation says

    int sqlite3_open(
    const char *filename,   /* Database filename (UTF-8) */
    sqlite3 **ppDb          /* OUT: SQLite db handle */
    );

Error in logcat

12-12 14:49:15.645: W/dalvikvm(3265): No implementation found for native Lcom/example/offline/NativeLib;.sqlite3_open:(Ljava/lang/String;Ljava/lang/Object;)I

So my question is can we create sqlite c object in our java

Here is my Android.mk file

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := sqlite3
LOCAL_SRC_FILES := sqlite3.c
include $(BUILD_SHARED_LIBRARY)

Thanx guys

Maveňツ
  • 1
  • 12
  • 50
  • 89
  • C interface will not work, methods are not even exposed. Exposed SQLite interface is wrapped in [SQLiteDatabase](http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html). – LS_ᴅᴇᴠ Dec 12 '13 at 09:48
  • Have you checked http://stackoverflow.com/questions/5523067/sqlite-with-android-ndk ? – LS_ᴅᴇᴠ Dec 12 '13 at 09:55
  • Why log says native method not found 12-12 16:50:48.980: E/AndroidRuntime(2094): java.lang.UnsatisfiedLinkError: Native method not found: com.shabdkosh.offline.NativeLib.sqlite3_open:(Ljava/lang/String;Ljava/lang/Object;)I – Maveňツ Dec 12 '13 at 11:22
  • Going to C, you must compile sqlite3.c in you NDK and somehow (I don't know) expose interface in JNI. – LS_ᴅᴇᴠ Dec 12 '13 at 12:07
  • Thanks @LS_dev but i have successfully created .so(binary) file by using ndk after that only i got the problem – Maveňツ Dec 12 '13 at 13:00

1 Answers1

1

what's your jni method?call native sqlite3_open(String filename,Object sqlite3) can not find language c sqlite3_open(const char *filename,sqlite3 **ppDb).

venciallee
  • 775
  • 4
  • 19
  • ur saying correct is there any other way to call the sqlite3_open(const char *filename,sqlite3 **ppDb). – Maveňツ Dec 13 '13 at 05:44
  • you need to know how to write jni.it's not very hard.search in google and do it.however the easy way to write jni,you can use swig. – venciallee Dec 13 '13 at 06:16