Search code examples
javascriptsqlitetitanium-mobile

Titanium appcelerator remove sqlite file from ressource folder?


I want to use titanium appcelerator sqlite features to save my remote datas to database. When i wanto to compile app, my file myDb.sqlite inside ressource folder is deleted by the studio and i get error :

[ERROR] :  Script Error {
[ERROR] :      column = 37;
[ERROR] :      line = 18;
[ERROR] :      message = "Could not retrieve attributes";
[ERROR] :      nativeLocation = "-[TiDatabaseProxy install:name:] (TiDatabaseProxy.m:136)";
[ERROR] :      nativeReason = "Error Domain=NSCocoaErrorDomain Code=260 \"The file \U201cremote.sqlite\U201d couldn\U2019t be opened because there is no such file.\" UserInfo={NSFilePath=/Users/esy/Library/Developer/CoreSimulator/Devices/44EEB566-359A-46BD-A456-C13DF1D4CF87/data/Containers/Bundle/Application/B274965B-515E-4785-B17A-AF36A457C034/syncAdapterDemo.app/mydata/remote.sqlite, 

Could you explain why please? and where exactly i can store this file ?

Thank you for help.


Solution

  • Is this an alloy app?

    If yes, then I would suggest placing the file in the app/assets folder.

    On build, it will then sit in the root of your project and you can access it as so:

    Ti.Database.install('/yourDb.sql', 'yourDb); for install.