[SailfishDevel] Fwd: Sharing a common OfflineStorage DB between multiple Sailfish apps.

christopher.lamb at thurweb.ch christopher.lamb at thurweb.ch
Thu Jan 16 12:14:05 UTC 2014

Hi all

This morning on the train on the way to work I tried the following to  
change the location of the offlineStorage DB:

The c++ main function of the demo app CreateDBQt5 now looks like this:

int main(int argc, char *argv[])
     QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
     QScopedPointer<QQuickView> view(SailfishApp::createView());
     qDebug() << "offlineStoragPath orig: " <<  
     qDebug() << "offlineStoragPath new: " <<  
     return app->exec();

This gives the following Application Output:
[D] main:42 - offlineStoragPath orig:   
[D] main:44 - offlineStoragPath new:   

The database is indeed created in  
/home/nemo/.local/share/landed25_QT5/QML/OfflineStorage", and is  
accessible to the app landed25_QT5

Note the order of the view->engine()->setOfflineStoragePath... and  
view->setSource... calls is crucial. If the setSource comes first,  
then the QML is initiated before the storagePath is changed!

In my next experiment I will try to change the storageLocation to  
something like QStandardPaths::GenericDataLocation.

The question on harbour acceptability remains ...


----- Weitergeleitete Nachricht von christopher.lamb at thurweb.ch -----
      Datum: Wed, 15 Jan 2014 22:34:40 +0100
        Von: christopher.lamb at thurweb.ch
Antwort an: "Sailfish OS Developers" <devel at lists.sailfishos.org>
    Betreff: [SailfishDevel] Sharing a common OfflineStorage DB  
between multiple Sailfish apps.
         An: "Sailfish OS Developers" <devel at lists.sailfishos.org>

Hi all

Is it possible to steer where a QML application stores its  
OfflineStorage Database?

I have a family of applications that share a common OfflineStorage  
Database. This works well on Harmattan, and on the early Sailfish  
Alphas without me having had to do anything special at all.

In the early Sailfish Alphas OfflineStorage DBs were stored in a  
common location, and thus could be easily shared.

Now on the real Jolla, I find that the standard DB storage location  
has changed, and DBs are now put in a subdirectory of the  
application's installation folder. e.g.


This means without some magic, Sailfish apps can no longer share DBs.

In C++ there is a property offlineStoragePath, and a setter method  


I might be able to use this to change the location of the DB, e.g to  
one of the Qt StandardLocations:


But setOfflineStoragePath() appears not to be directly available to QML.


So I guess I could call setOfflineStoragePath in each apps' main cpp file.

Or maybe I could even write a declarative plugin to expose  
setOfflineStoragepath to QML, but that is probably overkill as it  
would instantiate QQmlEngine - just t o set a path.

Or is there a better way? Are there any Harbour entry considerations  
to an app creating / accessing a DB somewhere other than in its own  



SailfishOS.org Devel mailing list

----- Ende der weitergeleiteten Nachricht -----

More information about the Devel mailing list