Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

Database Error on Android

$
0
0

Hello, my App (Android and iOS) is unsing a sqlite Database to store data. At the moment it's only used to save the language property like 'en' or 'es'. The Database is installing correctly on iOS and all the queries working fine, but not on Android. After hours of searching the mistake I'm pretty sure, the Database isn't installing on Android at all. My first question: Are there differnce between Android and ios when using a sqlite database? My second question: Is there a simple way to check if the database is installed, right on the device? My third question: Do you think this code should work? Thanks! db.js:

var db = Ti.Database.open('mystuff');
db.execute('CREATE TABLE IF NOT EXISTS lang(id INTEGER PRIMARY KEY, systemLang TEXT)') ;
 
//SET
exports.insertSystemLang = function(systemLang)
{   
  db.execute('INSERT INTO lang (systemLang) VALUES(?)',systemLang);
};
 
//UPDATE
exports.updateLang = function (_lang)
{
   db.execute('UPDATE lang SET systemLang=? WHERE id=1',_lang );    
};
 
//GET
exports.getSystemLang = function()
{    
  var lang = db.execute('SELECT (systemLang) FROM lang WHERE id=1'); 
  var myLang = lang.fieldByName('systemLang');
  return myLang;
};

Viewing all articles
Browse latest Browse all 7655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>