2012-11-21 27 views
1

我的iOS項目有一個SQLITE數據庫,我可以從我的本地IOS代碼訪問它。我可以訪問它並從中讀取數據。不能用phonegap打開sqlite數據庫,但它在objectiveC上工作正常

你可以看到我做它和下面的PIC我的項目結構的方式:enter image description here

,我嘗試做使用PhoneGap的一樣:

var db; 
    var shortName = 'myTestDb.db'; 
    var version = '1.0'; 
    var displayName = 'myTestDb'; 
    var maxSize = 65535; 


    // list the values in the database to the screen using jquery to 
    //update the #lbUsers element 
    function ListDBValues() { 

     if (!window.openDatabase) { 
      alert('Databases are not supported in this browser.'); 
      return; 
     } 
     $('#myDbElements').html(''); 

     db.transaction(function(transaction) { 
      transaction.executeSql("SELECT FIRST_NAME FROM dbo_RE_USER;", [], 
      function(transaction, result) { 
       console.log("result");         
       if (result != null && result.rows != null) { 
        console.log("result is not null"); 
        for (var i = 0; i < result.rows.length; i++) { 
         var row = result.rows.item(i); 
         //console.log(row); 
         debugObject(row); 


        $('#myDbElements').append('<br>' + row["FIRST_NAME"]);// + " " + row.LAST_NAME); 
        } 
       } 
      PrecApp.I_SCROLL.refresh(); 
      },errorHandler); 

     },errorHandler,nullHandler);   
     return; 
    } 

    function debugObject(obj) { 
    console.log("ROW:");   
    for (n in obj) 
//   alert(n + ":" + obj[n]); 
     console.log(n + ":" + obj[n]); 
    } 

但它不能找到我的dbo_re_users表。爲什麼?

回答

1

在JavaScript中打開的數據庫是完全不同的數據庫 - 它具有相同的名稱,但不在應用程序包中,該應用程序包是隻讀的。

如果您需要訪問特定的數據庫文件,則需要使用插件。

相關問題