Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2966] Android: Database - Incompatible change in SQLite file path argument of "install" method between 1.7.6 and 1.9

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2012-01-12T04:42:20.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterIvan Skugor
AssigneeMauro Parra-Miranda
Created2012-01-12T04:38:55.000+0000
Updated2016-03-08T07:47:58.000+0000

Description

Problem

There seems to be a change in "install" method of "Database" object regarding path to Sqlite file. From Titanium API documentation: https://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Database.install-method.html "the path (relative to the main application Resources folder at build time) to the db to install" In 1.7.6 I used path without starting "/". From 1.8.0.1 that does not work anymore, starting "/" must be present and it seems to me that included file path is relative to current JS file if starting "/" is not present. That can be seen with test case bellow. I'm not sure is that a bug or a feature, but it should be mentioned in docs in any case. :)

Test case

Ti.include('/db/install.js');
Ti.Database.install('test.sqlite', 'test_db');
"test.sqlite" is included as attachment and it has to be located in "Resources" directory. Compile this simple example with 1.7.6 and it will work, while it will fail with latest 1.9 (or 1.8.0.1).

Logs

01-12 13:17:10.634: E/TiApplication(4810): (KrollRuntimeThread) [269,362] APP PROXY: ti.modules.titanium.app.AppModule@408e9fc8
01-12 13:17:10.714: E/TiDatabase(4810): (KrollRuntimeThread) [78,440] Error installing database: test_db msg=Resources/db/test.sqlite
01-12 13:17:10.714: E/TiDatabase(4810): java.io.FileNotFoundException: Resources/db/test.sqlite
01-12 13:17:10.714: E/TiDatabase(4810): 	at android.content.res.AssetManager.openAsset(Native Method)
01-12 13:17:10.714: E/TiDatabase(4810): 	at android.content.res.AssetManager.open(AssetManager.java:315)
01-12 13:17:10.714: E/TiDatabase(4810): 	at android.content.res.AssetManager.open(AssetManager.java:289)
01-12 13:17:10.714: E/TiDatabase(4810): 	at org.appcelerator.titanium.io.TiResourceFile.getInputStream(TiResourceFile.java:63)
01-12 13:17:10.714: E/TiDatabase(4810): 	at ti.modules.titanium.database.DatabaseModule.install(DatabaseModule.java:126)
01-12 13:17:10.714: E/TiDatabase(4810): 	at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
01-12 13:17:10.714: E/TiDatabase(4810): 	at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:105)
01-12 13:17:10.714: E/TiDatabase(4810): 	at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:207)
01-12 13:17:10.714: E/TiDatabase(4810): 	at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:125)
01-12 13:17:10.714: E/TiDatabase(4810): 	at android.os.Handler.dispatchMessage(Handler.java:95)
01-12 13:17:10.714: E/TiDatabase(4810): 	at android.os.Looper.loop(Looper.java:132)
01-12 13:17:10.714: E/TiDatabase(4810): 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:102)
01-12 13:17:10.784: E/TiJSError(4810): (main) [65,505] ----- Titanium Javascript Runtime Error -----
01-12 13:17:10.784: E/TiJSError(4810): (main) [0,505] - In ti:/invoker.js:92,19
01-12 13:17:10.784: E/TiJSError(4810): (main) [0,505] - Message: Uncaught Error: Resources/db/test.sqlite
01-12 13:17:10.784: E/TiJSError(4810): (main) [0,505] - Source: 		return delegate.apply(invoker.__thisObj__, args);
01-12 13:17:10.814: D/dalvikvm(4810): GC_FOR_ALLOC freed 156K, 6% free 6528K/6919K, paused 22ms
01-12 13:17:10.814: I/dalvikvm-heap(4810): Grow heap (frag case) to 6.972MB for 513744-byte allocation
01-12 13:17:10.834: D/dalvikvm(4810): GC_FOR_ALLOC freed 4K, 6% free 7025K/7431K, paused 22ms
01-12 13:17:10.864: E/V8Exception(4810): Exception occurred at ti:/invoker.js:92: Uncaught Error: Resources/db/test.sqlite

Discussions

http://developer.appcelerator.com/question/130001/ics-error---tiinvokerjs-uncaught-error

Attachments

FileDateSize
test.sqlite2012-01-12T04:38:55.000+000098304

Comments

  1. Paul Dowsett 2012-01-12

    Thanks for this, Ivan. We are actually currently working on improving the apidocs on this. See TIMOB-4202.
  2. Ivan Skugor 2012-01-12

    OK, great. I'll put a reference to this ticket because, when calling "install" method, if path is not written as absolute (if it does not start with "/"), starting point won't be "Resources" directory, but directory in which JS file that calls "install" is located (that's not mentioned there).
  3. Mauro Parra-Miranda 2013-11-24

    DUP issue.

JSON Source