Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problem using Qt's JNI interface, No valid jobjects
QtWS25 Last Chance

Problem using Qt's JNI interface, No valid jobjects

Scheduled Pinned Locked Moved Mobile and Embedded
androidjnisqlqsqlite
3 Posts 2 Posters 1.4k Views
  • 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 Offline
    N Offline
    Nightrush0179
    wrote on last edited by
    #1

    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
    0
    • K Offline
      K Offline
      kolegs
      wrote on last edited by
      #2

      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
      1
      • N Offline
        N Offline
        Nightrush0179
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved