I can not get a database to install for android. As soon as the app launches it comes up with "Cannot call method "execute" on null." I've renamed the database with an extension of mp3. I've also tried using ddms to put in the database onto the emulator as prescribed <a href="http://developer.appcelerator.com/question/61591/problem-with-sqllite-db-on-android">here: http://developer.appcelerator.com/question/61591/problem-with-sqllite-db-on-android </a> but where exactly would I put it? I've put it in a number of spots and still no luck.
1 Answer
You cannot use the .execute method until you have either done an .open() or .install() on the database (and they worked). So it would help if you showed us the code that is failing. In general, if you are trying to include a prebuilt SQLite database with your program you can do this:
- Add the file to your project Resources folder prior to compilation
- If the file is over 5MB, change the extension to *.mp3
- In the app.js file, do this
var db = Ti.Database.install('myDb.mp3','myDb'); if ( db ) { db.execute('Select * from myTable'); } else { alert('Database install failed'); }
Your Answer
Think you can help? Login to answer this question!