Problem using Qt's JNI interface, No valid jobjects
-
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. -
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.
-
Thank you, with the StandardPaths's its working with QSqlDatabase.
But does anybody know how to solve the above mentioned problem?