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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:21:39+00:00 2026-05-28T01:21:39+00:00

I am getting an error while trying to insert an item into my database.

  • 0

I am getting an error while trying to insert an item into my database.

This is what Logcat reads:

android.database.sqlite.SQLiteException table game has no column named title: , while compiling: INSERT INTO game(title, rating, info)  VALUES (?, ?, ?);

This is my database manager:

package com.herring.android.finalproject;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class GameDataBaseManager {

    private DatabaseHelper mDbHelper;
    private SQLiteDatabase mDb;
    private static final String DATABASE_NAME = "data";
    private static final int DATABASE_VERSION = 1;  
    private final Context mCtx;
    private static final String GAME_TABLE_NAME = "game";
    public static final String KEY_ROWID = "_id";
    public static final String KEY_TITLE = "title";
    public static final String KEY_BODY = "info";
    public static final String KEY_RATING = "rating";
    private static final String GAME_TABLE_CREATE = "create table " + GAME_TABLE_NAME + " ( " + 
            KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
            KEY_TITLE + " TEXT NOT NULL, " +
            KEY_BODY + " TEXT NOT NULL, " + 
            KEY_RATING + " NUM NOT NULL );";


    public GameDataBaseManager(Context ctx)
    {
        this.mCtx = ctx;
    }


    public long addRow(String rowStringOne, String rowStringTwo, float rating)
    {
        ContentValues values = new ContentValues();
        values.put(KEY_TITLE, rowStringOne);
        values.put(KEY_BODY, rowStringTwo);
        values.put(KEY_RATING, rating);
        return mDb.insert(GAME_TABLE_NAME, null, values);
    }
    public void deleteRow(long rowID)
    {
        try
        {
            mDb.delete(GAME_TABLE_NAME, KEY_ROWID + " = " + rowID, null);
        }
        catch(Exception e)
        {
            Log.e("DB ERROR", e.toString());
            e.printStackTrace();
        }
    }


    public GameDataBaseManager open() throws android.database.SQLException
    {
        mDbHelper = new DatabaseHelper(mCtx);
        mDb = mDbHelper.getWritableDatabase();
        return this;
    }

    public void close()
    {
        mDbHelper.close();
    }

    public Cursor getAllGames()
    {
        return mDb.query(GAME_TABLE_NAME, null, null,
                null, null, null, null);
    }

    public Cursor fetchGame(long rowId) throws SQLException
    {
        Cursor mCursor = mDb.query(true, GAME_TABLE_NAME, new String[]{KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_RATING}, 
                KEY_ROWID + "=" + rowId, null, null, null, null, null);
        if(mCursor != null)
        {
            mCursor.moveToFirst();
        }
        return mCursor;
    }

    public boolean updateDb(long rowId, String title, String body, String rating)
    {
        ContentValues args = new ContentValues();
        args.put(KEY_TITLE, title);
        args.put(KEY_BODY, body);
        args.put(KEY_RATING, rating);

        return mDb.update(GAME_TABLE_NAME, args, KEY_ROWID + " = " + rowId, null) > 0;
    }

    public class DatabaseHelper extends SQLiteOpenHelper {
        public DatabaseHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(GAME_TABLE_CREATE);

        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        }
    }
}

Here is the Activity where I try to insert the item:

package com.herring.android.finalproject;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class TopRatedActivity extends Activity {
    private Cursor gamesCursor;
    private ListView lv;
    private GameDataBaseManager mDbHelper;
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        mDbHelper = new GameDataBaseManager(this);
        mDbHelper.open();
        mDbHelper.addRow("Game", "Info", 0);
        setContentView(R.layout.toprated);
        fillData();

    }
    private void fillData()
    {
        gamesCursor = mDbHelper.getAllGames();
        startManagingCursor(gamesCursor);
        String[] from = new String[]{GameDataBaseManager.KEY_TITLE};
        int[] to = new int[]{R.id.text1};
        SimpleCursorAdapter games = new SimpleCursorAdapter(this, R.layout.toprateditem, gamesCursor, from, to);
        lv.setAdapter(games);
    }
}

Any help would be greatly 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-05-28T01:21:40+00:00Added an answer on May 28, 2026 at 1:21 am

    You have a table named “game” in your database. But it doesn’t have a column called “title”. You could try deleting the entire database and creating it again.

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

Sidebar

Related Questions

im getting this error while trying to connect a mysql database to an editor,
I'm getting error Not unique table/alias while trying to display data from MySQL database
I am facing a really weird error,while trying to insert into a table called
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
I keep getting this error while trying to modify some tables. Here's my code:
All of a sudden I start getting this error while trying to open 2
While trying to host the CLR, I keep getting this: error C2440: 'function' :
I am getting an error while trying to run this Application ... the error
Can anyone provide any input on this error. I am trying to insert into
I am getting this error while trying to run an ajaxq call. I am

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.