Solved Qt Mobile Application for Android
-
@divaindie have you tried it this way ? https://stackoverflow.com/a/40713888/135559
or this: https://forum.qt.io/topic/94088/deploy-sqlite-database-with-apk/12
-
@ekkescorner i tried the link https://forum.qt.io/topic/94088/deploy-sqlite-database-with-apk/12
but i got below error message while copying db file to a writable location ( i.e QStandardPaths::writableLocation(QStandardPaths::StandardLocation::AppDataLocation); )
W QtMainThread: type=1400 audit(0.0:119): avc: denied { link } for name="qt_temp.xajbeT" dev="dm-0" ino=124288 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file permissive=0
edit1 : it works if i use "QStandardPaths::GenericDataLocation" instead of "QStandardPaths::StandardLocation::AppDataLocation".
now my question is which location i should prefer using to copy my database file from assets:/ folder ? .(FYI both read/write opearion allowed on database file) -
@divaindie what's your Qt version ?
there were issues with temp files causing errors while copying on Android
5.10.1 and 5.11.1 should be ok -
@ekkescorner iam using 5.10.1 !!! .which version of Qt works fine for developing Android applications?
-
@divaindie 5.10.1 should be fine.
can you create, save and copy a normal text file at your AppDataLocation ? -
@ekkescorner Iam able to create files.but i cant read/write/copy files to AppDataLocation
-
@divaindie curios.
I'm using this to get the appdata locationmDataRoot = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).value(0);
then I'm checking if the directory exists, but this should exists on Android, but must be created on iOS
to be safe I'm always checkingQDir myDir; bool exists; exists = myDir.exists(mDataRoot); if (!exists) { bool ok = myDir.mkpath(mDataRoot); if(!ok) { qWarning() << "Couldn't create mDataRoot " << mDataRoot; return false; } qDebug() << "created directory mDataRoot " << mDataRoot; }
then as next I'm creating a /data/ directory and place all my other files ond folders inside this
never had problems with read write delete copy -
@ekkescorner this worked for me.thanks!!.
for linux & windows if i want to add my database file what changes i need to make in .pro file ?.
for android i made below changes.
android
{
my_files.path = /assets
my_files.files = $$PWD/android/*
INSTALLS += my_files
} -
@divaindie good to hear that it's working for you
-
@divaindie said in Qt Mobile Application for Android:
for linux & windows if i want to add my database file what changes i need to make in .pro file ?
Maybe it'd be good you mark this post as solved since you originally asked for Android and it's working for you now, and open a new post for the other platforms so not to hijack the post. Thanks.