I am so confused.
Around the internet there are 100 different document with a 100 different methods of getting a database to install and run in your app.
All I really want is the one sure fire way of getting a pre-exsiting sqlite database installed into the app,so the database is persistent (not killed every time I build).
I have looked at the kitchen sink, and the persistence example, both which use sql statements to build the table before working with the database.
Can someone please help me out? I have wasted half a day looking/reading/watching all I can on the internet to only be left with not being sure of what I really need to do to get a datbase working in my app.
My database is located in Resources/database/efdata.db and efdata.sqlite . I don't care which file is used, I was watching youTube and someone said appcelerator doesn't read sqlite files, so I renamed it.
Based on (http://developer.appcelerator.com/question/9161/how-to-test-persistent-storage) I think that I need to install the database and then open it from the app directory.
var efSonar = Ti.Database.install('/database/efdata.db', 'efdatav01'); efSonar.close(); var separator = Titanium.Filesystem.getSeparator(); var dbFile = Titanium.Filesystem.getFile(Titanium.Filesystem.getResourcesDirectory() + separator + "efdatav01"); var efSonar = Titanium.Database.open(dbFile);I get an error
[ERROR][SQLiteLog( 898)] (14) cannot open file at line 30174 of [00bb9c9ce4] [ERROR][SQLiteLog( 898)] (14) os_unix.c:30174: (2) open(/file:/android_asset/Resources/efdatav01) - [ERROR][SQLiteDatabase( 898)] Failed to open database '/file:/android_asset/Resources/efdatav01'. [ERROR][SQLiteDatabase( 898)] android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database [ERROR][TiJSError( 898)] (main) [414,1759] ----- Titanium Javascript Runtime Error ----- [ERROR][TiJSError( 898)] (main) [1,1760] - In app.js:40,35 [ERROR][TiJSError( 898)] (main) [1,1761] - Message: Uncaught Error: Java Exception occurred [ERROR][TiJSError( 898)] (main) [1,1762] - Source: var efSonar = Titanium.Database.open(dbFile); [ERROR][V8Exception( 898)] Exception occurred at app.js:40: Uncaught Error: Java Exception occurred
Thanks for the help. I really would like to get this app off the ground.
1 Answer
Try var efSonar = Titanium.Database.open('efdatav01'); instead. No need to go get a file path or whatnot.
Your Answer
Think you can help? Login to answer this question!