App keeps crashing when accessing sqlite database

I'm try to access a database which was working fine (until i added more fields and updated the code accordingly).

I get this error:

Caused by: android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: SELECT _id, title, description, locations, datesTimes, added, provider, url, cast, director, runningTime, certification, imageUrl, trailerUrl FROM films ORDER BY _id DESC

Here is the code for the query:

public Cursor getAllTitles() { return myDataBase.query("films", new String[] { KEY_ROWID, KEY_TITLE, KEY_DESCRIPTION, KEY_LOCATIONS, KEY_DATESTIMES, KEY_ADDED, KEY_PROVIDER, KEY_URL, KEY_CAST, KEY_DIRECTOR, KEY_RUNNINGTIME, KEY_CERTIFICATION, KEY_IMAGEURL, KEY_TRAILERURL}, null, null, null, null, KEY_ROWID + " DESC"); //Sort the data using the Primary Key in descending order . . meaning last added is shown first. }

And here the code for extracting data from the database:

//---Get all records from database--- myDbHelper.openDataBase(); cursorPosition = myDbHelper.getAllTitles(); if (cursorPosition.moveToFirst()) { do { AddRecordToArray(cursorPosition); } while (cursorPosition.moveToNext()); } myDbHelper.close(); } public void AddRecordToArray(Cursor cursorPosition) { //Add new record to array (which gets data from database using cursorPosition (for current row) and .getstring( for column number). final FilmRecord film1 = new FilmRecord(cursorPosition.getString(1), cursorPosition.getString(4), cursorPosition.getString(5), cursorPosition.getString(3), cursorPosition.getString(2), cursorPosition.getString(6), cursorPosition.getString(7), cursorPosition.getString(8), cursorPosition.getString(9), cursorPosition.getString(10), cursorPosition.getString(11), cursorPosition.getString(12), cursorPosition.getString(13)); films.add(film1); myDbHelper.close(); } @Override protected void onDestroy() { super.onDestroy(); if (myDbHelper != null) { myDbHelper.close(); } }

If there is any more information required to solve this error just let me know what you need. I'm really confused with the ",".

-------------Problems Reply------------

"cast" is a reserved word. Try changing that column name, or quoting it.

Please change the value of the key KEY_CAST from cast to some other value because the cast is a reserve word.

Category:android Views:0 Time:2012-03-01

Related post

  • Accessing SQLite database from command line 2012-01-15

    I am trying to access SQLite database from command line for an android application I have developed. I type adb shell to connect to the device and then sqlite3 to connect to the database. sqlite3 gives me the following an error: /system/bin/sh: sqlit

  • AsyncTask that accesses Sqlite database causes crash 2011-06-23

    I have a ListView which I need to populate using a background thread. The list needs to update as each item is retrieved. Below is a very simplified example of how I implement this. public class DownloadTask extends AsyncTask <MyUserObject, Intege

  • Access sqlite database on android device 2011-01-31

    This question already has an answer here: where is my app? /data appears empty 3 answers I'm trying to access the sqlite database file on the device. I mean, I've launched the app on the device via adb. And now I wanto to download this file as I did

  • accessing .sqlite database (>1Mb size) in android 2011-05-15

    I am working on a library app and have books stored as .sqlite files. Each book's sqlite database file is about 10MB in size. I first tried to put it in assets folder and then copying it to database/ folder but since the file is >1Mb this gives me

  • How to access sqlite database inside the widget class? 2011-06-02

    How to access the sqlite databases inside the widget class. The widget class which extends the appwidgetprovider does not have an activity hence i am not able to access the databases inside it. Please provide a detailed description on how to do it. T

  • CursorIndexOutOfBoundsException when accessing Sqlite database 2011-08-19

    Hi everyone I’ve been having some difficulty, hope one of you can help. I’m trying to create a little program to store my timetable for college. I’ve been having some trouble with the SQlite database though, it’s got me stumped. When I first run the

  • Accessing Sqlite Database from Sd Card 2012-03-02

    I have stored my database on the SD card and now I'm trying to access it but it gives me an error : 03-02 15:36:09.653: E/AndroidRuntime(27299): FATAL EXCEPTION: main 03-02 15:36:09.653: E/AndroidRuntime(27299): java.lang.RuntimeException: Unable to

  • Accessing SQLite database from another class 2012-04-28

    I've created a sample SQLite database in Android that reads entries into a ListView. I'm going to add code so that when clicked, each ListView item starts a new activity to display more information. How can I run queries on this database from within

  • access sqlite database using dropdown list 2011-07-16

    I create database using sqlite3. I want to know if there is any software out there allow me to access the database without typing "SELECT name FROM table WHERE last='lastname'" in the cli. A gui software that have dropdown list or auto fill in, so i

  • Android accessing SQLite Database from multiple threads 2011-08-22

    I have a SQLite Database in android that is accessed from a thread when the activity is running, and in the onPause() of the activity a new thread is created to save everything into the database with a different thread to avoid timeout issues. Howeve

  • How to adapt Apple singleton pattern for accessing SQLite database? 2011-09-21

    Has anyone developed a singleton for accessing SQLite db? I know that there are other options like Core Data but, in my case, I need SQLite. I have looked at Apple provided singleton creation code (here) but the thing is SQLite database "stuff" is no

  • How to access sqlite database which already exists in android 2011-12-08

    I have created an sqlite databse and put it into the assets folder. How can I access it? I have created a database helper class also, but my data is "not taking the path". Plz help me Thanks --------------Solutions------------- Copy your database fil

  • how to accessing sqlite database from java class 2012-01-23

    I have created sqlite database using phonegap. I am able to access that databse within the javascript. But I want access that sqlitedatabase from java class. It is possible? Thanks in andvance.. --------------Solutions------------- For PhoneGap --SQL

  • Access sqlite database through network stream 2012-04-14

    I am wondering if there is a way of treating a network stream as a file. I might be wrong but I see a file as an array list of bytes. when you open a file in windows and you write to it you are inserting bytes to that file (array list) I believe. I a

  • Accessing SQLite database with PHP 2010-08-23

    I am interested in using a SQLite database in my next project because it needs to be ultra-portable and a simple file that a class can connect to and use as a database seems perfect. After Google'ing a bit I found this:

  • Cannot access Sqlite Database (of Firefox) using System.Data.Sqlite 2011-03-29

    I wrote a small C#/.Net application that is able to read the cookies.sqlite file of Firefox. Since I upgraded to Firefox 4 my application is not able to open the database file: Executing the line "connection.Open();" (in the code sample below) there

  • Access SQLite database from non-android environment 2011-11-11

    Here is my situation: I have two sets of tests for my android application. One set that uses "normal" non-android libraries (JUnit4, JMock2, etc.), to unit-test my business logic, and one set that uses the Android framework (ActivityInstrumentationTe

  • App crash on access new Database 2009-10-09

    My application crashes on reading / writing data from the database. I have one database on c: and I copy-pasted and rename with different name. The following process is what I have used for copy...Please guide me if you have any suggestion or solutio

  • How can I store and access SQLite databases from a central location? 2010-04-24

    I have installed SQLite on my UNIX system, and am planning on accessing it from PHP. However, the database is created in the directory I initialize it in, and if a script runs in a different directory a new database is created in the same directory.

Copyright (C), All Rights Reserved.

processed in 0.101 (s). 11 q(s)