Loading a database on mobile devices
Before continuing the UI implementation, we have to handle database deployment on mobile devices (spoiler alert: this will not be fun!).
We have to jump back to DatabaseManager.cpp
in the gallery-core
project:
DatabaseManager& DatabaseManager::instance() { return singleton; } DatabaseManager::DatabaseManager(const QString& path) : mDatabase(new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE"))), albumDao(*mDatabase), pictureDao(*mDatabase) { mDatabase->setDatabaseName(path); ... }
Although, on desktop devices, the SQLite3 database is created with the instruction mDatabase->setDatabaseName()
, on mobile devices, it does not work at all. This is due to the fact that the filesystem is very specific on each mobile platform (Android and iOS). An application only has access to a narrow sandbox where it cannot interfere with the rest of the filesystem. All the files inside the application directory must have specific...