SQLite database on Android.

387 views
Skip to first unread message

Maciej Płaza

unread,
Dec 4, 2011, 12:45:05 PM12/4/11
to android-qt
Hi,

I need your help. I'm writing application where I use SQLite database.
My problem is that I can't open database on Android side. I need read
and write permissions.
1. I tried assets like in tutorial but it doesn't work for me.
2. I did something like this:
"# Add more folders to ship with the application, here
QMLfiles.source = qml/roja
QMLfiles.target = qml

ContentFiles.source = content/roja
ContentFiles.target = content

DEPLOYMENTFOLDERS += QMLfiles \
ContentFiles"
and
2a. QFile file("content/roja/RojaDatabase.sqlite.db");
qDebug() << file.exists();
shows that file exists.
2b.
rojaDatabase = QSqlDatabase::addDatabase("QSQLITE");
rojaDatabase.setDatabaseName("content/roja/RojaDatabase.db.sqlite");
rojaDatabase.open();
qDebug() << rojaDatabase.lastError().text();
shows:
"unable to open database file Error opening database".

3. I tried copy my database to /data/data/MYAPP/files but still nothing.

I really doesn't have any idea how make it run :/ Please help.

Thanks in advance and best regards.
--
Maciej Płaza.

Enrico Miglino

unread,
Dec 4, 2011, 12:53:23 PM12/4/11
to andro...@googlegroups.com
Hi,

we are near to release QtComplex 2.0 that includes a database class that is in testing in these days. You can download the branch dbtest from the qt complex 2.0 gitorious repo (https://gitorious.org/qt-complex/qtcomplex) and check if it can be useful for you.

Enrico

2011/12/4 Maciej Płaza <plaza....@gmail.com>

Maciej Płaza

unread,
Dec 4, 2011, 2:59:13 PM12/4/11
to andro...@googlegroups.com
W dniu 4 grudnia 2011 18:53 użytkownik Enrico Miglino
<enrico....@gmail.com> napisał:
Hi,

Thanks for fast answer. Your solution (from QtComplex) works excellent
on Android (I didn't tested it on other systems) but I have one
question. What when somebody wouldn't have SDCARD? Is there some way
to keep this file on internal storage?

Best regards.
--
Maciej Płaza.

Reply all
Reply to author
Forward
0 new messages