Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:53:15+00:00 2026-06-09T09:53:15+00:00

In my application I have a database. Although I can insert into the table

  • 0

In my application I have a database. Although I can insert into the table successfully but I have problem in updating a field.

This code creates my table:

public final static String[] TABLES_NAME = {"general", "toprecipes", "favorites", "shoppinglist"};
//-- Columns of table: shopping list
    public final static String[] CLM_SHOPPINGLIST = {COLUMN_ID, "resepiId", "resepiName", "ingredient", "status"};
    private final String CRT_TBL_SHOPPINGLIST = "CREATE TABLE " + TABLES_NAME[3] + " (" + 
        CLM_SHOPPINGLIST[0] + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
        CLM_SHOPPINGLIST[1] + " TEXT," + 
        CLM_SHOPPINGLIST[2] + " TEXT," + 
        CLM_SHOPPINGLIST[3] + " TEXT," + 
        CLM_SHOPPINGLIST[4] + " TEXT"  + 
        ");";

I need that based on an event, set the status of item from “T” to “F” and vice versa.

For updating the database I have this code:

public void updateRecordStatus(String resepiName, String ingredientName, String status) {
        ContentValues cv = new ContentValues();
        cv.put(DatabaseHelper.CLM_SHOPPINGLIST[4], status);

        database.update(DatabaseHelper.TABLES_NAME[3], cv, DatabaseHelper.CLM_SHOPPINGLIST[2] + "=" + resepiName + " AND " + DatabaseHelper.CLM_SHOPPINGLIST[3] + "=" + ingredientName, null);

        Log.i(TAG, "Status of ingredient '" + ingredientName + "' updated to '" + status + "' in table.");
    }

It seems everything is ok but I have no idea why — when I run the app and want to update, it crashes. Logcat shows these messages and points to database.update(...):

08-07 08:08:03.289: I/Database(460): sqlite returned: error code = 1, msg = near "Bakar": syntax error
08-07 08:08:03.289: E/Database(460): Error updating status=T using UPDATE shoppinglist SET status=? WHERE resepiName=Terung Bakar Mediterrinean AND ingredient=2 biji lemon
08-07 08:08:03.289: W/dalvikvm(460): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-07 08:08:03.323: E/AndroidRuntime(460): FATAL EXCEPTION: main
08-07 08:08:03.323: E/AndroidRuntime(460): android.database.sqlite.SQLiteException: near "Bakar": syntax error: , while compiling: UPDATE shoppinglist SET status=? WHERE resepiName=Terung Bakar Mediterrinean AND ingredient=2 biji lemon
08-07 08:08:03.323: E/AndroidRuntime(460):  at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
08-07 08:08:03.323: E/AndroidRuntime(460):  at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
08-07 08:08:03.323: E/AndroidRuntime(460):  at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
08-07 08:08:03.323: E/AndroidRuntime(460):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
08-07 08:08:03.323: E/AndroidRuntime(460):  at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
08-07 08:08:03.323: E/AndroidRuntime(460):  at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1145)
08-07 08:08:03.323: E/AndroidRuntime(460):  at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1671)
08-07 08:08:03.323: E/AndroidRuntime(460):  at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1622)
08-07 08:08:03.323: E/AndroidRuntime(460):  at com.astro.recipe.database.DBShoppingListHandler.updateRecordStatus(DBShoppingListHandler.java:107)
08-07 08:08:03.323: E/AndroidRuntime(460):  at com.astro.recipe.activities.ShoppingList$2.OnCheckChangedListener(ShoppingList.java:90)

Any comments or suggestion would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:53:17+00:00Added an answer on June 9, 2026 at 9:53 am

    String literals must be enclosed in single quotes.

    for example:

    Where you='jox' AND authenticated='1'
    

    keep in mind that you and authenticated are column names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database application in which a group is modeled like this: TABLE
I'm trying to insert registration data into a database but my php code isn't
Can I host an application in Windows Azure and have the database stored on
I'm using LINQ, but my database tables do not have an IDENTITY column (although
I'm designing a contact manager/address book-like application but can't settle on the database design.
I'm designing a contact manager/address book-like application but can't settle on the database design.
I have an existing SQL Server database whose structure I can't really change, although
I have a table in my database formatted like this: customer old_code new_code C1
I have database application, I want to allow the user to restore the deleted
In my application I have a complex database structure. In order to generate the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.