Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Problem using Qt's JNI interface, No valid jobjects

    Mobile and Embedded
    android jni sql qsqlite
    2
    3
    1157
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      Nightrush0179 last edited by

      Hello,

      I am trying to call SQLiteDatabase's function "SQLiteDatabase openOrCreateDatabase (String path, SQLiteDatabase.CursorFactory factory)" (Andoird, see the link below)
      http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#openOrCreateDatabase(java.lang.String, android.database.sqlite.SQLiteDatabase.CursorFactory)

      This is the way I tried it:

      qDebug() << "Object valid?: " <<
                  QtAndroid::androidActivity().
                  callStaticObjectMethod("android/database/sqlite/SQLiteDatabase",
                                         "openOrCreateDatabase",
                                         "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;",
                                         QAndroidJniObject::fromString("data/data/<full appname>/databases/SomeDatabase.sqlite")
                                         .object<jstring>(),
                                         jobject(0)).isValid();
      

      But the ouput says "Object valid?: false". So now my question, whats the probem here?
      Or maybe there is a better way to solve my problem in gerneral. I want to use a sqlite database on Andoird. I can create the database, but I cannot save it to the local file system for some reason. So I tried it this way.

      1 Reply Last reply Reply Quote 0
      • K
        kolegs last edited by

        You can use Qt libaries(QSqlDatabase, QSqlQuery) and they works just fine, had no problems with them.
        About saving file use library QStandardPaths to get path to documents and save the file there. On mobile devices there are some restrictions about directories where you can save your files.

        Hope it helps.

        1 Reply Last reply Reply Quote 1
        • N
          Nightrush0179 last edited by

          Thank you, with the StandardPaths's its working with QSqlDatabase.
          But does anybody know how to solve the above mentioned problem?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post