Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23386] Android: SQLite dataBase file is not installed properly.

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2016-05-19T03:17:20.000+0000
Affected Version/sRelease 5.2.2
Fix Version/sn/a
ComponentsAndroid
LabelsAndroid, database, iOS, sqlite
ReporterMotiur Rahman
AssigneeAshraf Abu
Created2016-05-07T18:58:19.000+0000
Updated2017-03-24T17:57:11.000+0000

Description

When we place the sqlite database file into the asset or lib folder of Alloy project then it can not detect the table inside the dataBase file and always shows the below error.

Steps To Reproduce

1. Just create a Alloy project. 2. Paste the following code into the index.js file 3. Download the database file and paste into the lib or assets folder. 4. Finally, run your project. Note: If you open the dataBase file by the sqlite manager, you can see the dataBase table.

Test Code

function doCllick(e) {

	var db = Ti.Database.install('m9data.sqlite', 'm9data'); 
	var result = db.execute("select*from config");
	Ti.API.info("DataBaseTest" + result);
	db.close(); 

}

$.index.open();

Android Error

[ERROR] :  TiExceptionHandler: (main) [59,235057] ----- Titanium Javascript Runtime Error -----
[ERROR] :  TiExceptionHandler: (main) [0,235057] - In undefined:14,25
[ERROR] :  TiExceptionHandler: (main) [0,235057] - Message: Uncaught Error: no such table: config (code 1): , while compiling: select*from config
[ERROR] :  TiExceptionHandler: (main) [0,235057] - Source:         var result = db.execute("select*from config");

Attachments

FileDateSize
app.zip2016-05-18T18:50:59.000+00001494277
m9data.sqlite2016-05-07T18:31:24.000+000065536

Comments

  1. Ashraf Abu 2016-05-18

    Adding classic app as example:-
       var win = Ti.UI.createWindow();
       win.addEventListener('open', function(){
           
          
       var db = Ti.Database.install('m9data.sqlite','m9datadb');
       var dbOpen = Ti.Database.open('m9datadb');
       allData = dbOpen.execute("SELECT * FROM config");
       while (allData.isValidRow()) {
               //var name = allData.fieldByName('name');
               //Ti.API.info("DB name:"+name);
               
               var cod = allData.fieldByName('AgencyCode');
               var tag = allData.fieldByName('ServiceTag');
               var bit = allData.fieldByName('FeatureBit');
               var city = allData.fieldByName('AgencyCity');
               Ti.API.info(cod + ' ' + tag + ' ' + bit + ' ' + city + ' ');
               
               allData.next();
       }
       dbOpen.close();
           
       });
        
       win.open();
       
    m9data.sqlite was placed in Resources folder for this classic app.
  2. Feon Sua Xin Miao 2016-05-18

    [~msamah] attached alloy app using m9data.sqlite.
  3. Ashraf Abu 2016-05-19

    Thank you [~fmiao]
  4. Ashraf Abu 2016-05-19

  5. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source