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 8967155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:11:06+00:00 2026-06-15T17:11:06+00:00

So basically the code works fine until i hit the line i commented //THIS

  • 0

So basically the code works fine until i hit the line i commented “//THIS DOESNT WORK!!!”. then nothing is entered into the database. Anyone know why i can enter them fine for the “StringCategory_Table” but not the other ones?

public class SetupOfSQLite{


    private DBHelper myHelper;
    private final Context myContext;
    private SQLiteDatabase myDatabase;

     private static final String DATABASE_NAME = "restaurantDatabase";
     private static final int DATABASE_VERSION = 1;
     private static final String COLUMN_RESTAURANT = "RestaurantName";
     private static final String COLUMN_CATEGORIES= "CategoryName";

     public static String currentRestaurant = null;
     public static String deletingRestaurant= null;

     public static final String American_Table ="Restaurant_List_American";
     public static final String Asian_Table = "Restaurant_List_Asian";
     public static final String BarPub_Table = "Restaurant_List_BarPub";
     public static final String Breakfast_Table ="Restaurant_List_Breakfast";
     public static final String FastFood_Table ="Restaurant_List_FastFood";
     public static final String Healthy_Table = "Restaurant_List_Healthy";
     public static final String Mexican_Table ="Restaurant_List_Mexican";
     public static final String SeaFood_Table = "Restaurant_List_SeaFood";
     public static final String Italian_Table = "Restaurant_List_Italian";
     public static final String Deserts_Table = "Restaurant_List_Desert";
     public static final String StringCategory_Table = "Categories_of_Restaurants";

     static ContentValues contValues = new ContentValues();

private static class DBHelper extends SQLiteOpenHelper {

public DBHelper (Context ctx){
     super (ctx, DATABASE_NAME, null, DATABASE_VERSION);
     }

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE " + American_Table       + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");  
    db.execSQL("CREATE TABLE " + Asian_Table          + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    db.execSQL("CREATE TABLE " + BarPub_Table         + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    db.execSQL("CREATE TABLE " + Breakfast_Table      + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    db.execSQL("CREATE TABLE " + Deserts_Table        + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    db.execSQL("CREATE TABLE " + FastFood_Table       + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    db.execSQL("CREATE TABLE " + Healthy_Table        + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    db.execSQL("CREATE TABLE " + Italian_Table        + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    db.execSQL("CREATE TABLE " + Mexican_Table        + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    db.execSQL("CREATE TABLE " + SeaFood_Table        + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_RESTAURANT + " TEXT NOT NULL);");
    // The table below is for keeping the categories persistent
    db.execSQL("CREATE TABLE " + StringCategory_Table + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_CATEGORIES + " TEXT NOT NULL);");
    // The table below is for suggestions

    // now I'll create some entries for default categories
    contValues.put(COLUMN_CATEGORIES, "American"); 
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "Asian");
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "Bar or Pub");
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "Breakfast");
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "Deserts");
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "FastFood");
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "Healthy"); // this represents "Healthy" category
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "Italian");
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "Mexican");
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

    contValues.put(COLUMN_CATEGORIES, "SeaFood");
    db.insert(StringCategory_Table, COLUMN_CATEGORIES, contValues);

// now ill add in some restaurants for the first time the user installs the app 
//THIS DOESNT WORK!!!

    contValues.put(COLUMN_RESTAURANT, "Olive Guarden"); 
    db.insert(Italian_Table, COLUMN_RESTAURANT, contValues);

    contValues.put(COLUMN_RESTAURANT, "Red Lobster"); 
    db.insert(SeaFood_Table, COLUMN_RESTAURANT, contValues);

    contValues.put(COLUMN_RESTAURANT, "Outback"); 
    db.insert(American_Table, COLUMN_RESTAURANT, contValues);

    contValues.put(COLUMN_RESTAURANT, "Dunkin' Donuts"); 
    db.insert(Breakfast_Table, COLUMN_RESTAURANT, contValues);

    contValues.put(COLUMN_RESTAURANT, "Taco Bell"); 
    db.insert(Mexican_Table, COLUMN_RESTAURANT, contValues);

    contValues.put(COLUMN_RESTAURANT, "Burger King"); 
    db.insert(FastFood_Table, COLUMN_RESTAURANT, contValues);  //1st entry for fast food

    contValues.put(COLUMN_RESTAURANT, "McDonald's"); 
    db.insert(FastFood_Table, COLUMN_RESTAURANT, contValues);  // 2 entries for fast food

    contValues.put(COLUMN_RESTAURANT, "Cold Stone"); 
    db.insert(Deserts_Table, COLUMN_RESTAURANT, contValues);

    contValues.put(COLUMN_RESTAURANT, "Panda"); 
    db.insert(Asian_Table, COLUMN_RESTAURANT, contValues);

    contValues.put(COLUMN_RESTAURANT, "Subway"); 
    db.insert(Healthy_Table, COLUMN_RESTAURANT, contValues);

}
  • 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-15T17:11:07+00:00Added an answer on June 15, 2026 at 5:11 pm

    I think your contValues variable has stale column information that is not meaningful for the restaurant tables. Try the following:

    contValues.clear();
    contValues.put(COLUMN_RESTAURANT, "Olive Guarden"); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a piece of code that works fine. It basically loops through each
I am having a problem getting this code to work. Basically I Go from
So basically this code was working fine before. I had some computer issues and
This code works fine if I move the findViewById call in to the Activity.
The following code basically works as expected. However, to be paranoid, I was wondering,
This code basically translates characters based on position in one string to the character
So basically this code: class A { }; class B { B (const B&
I have (basically) this code - <script type=text/javascript language=javascript> $(document).ready(function() { $(#loadDiv).load(mypage.html, function(){ alert($(#someText).text())
This is a follow up from my previous question I have this code basically
I have this delphi code that basically download a file (using Delphi 2010 +

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.