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

  • Home
  • SEARCH
  • 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 6542065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:10:51+00:00 2026-05-25T11:10:51+00:00

My app’s got a database with three tables in it: one to store the

  • 0

My app’s got a database with three tables in it: one to store the names of the people it tracks, one to track an ongoing event, and one – for lack of a better term – for settings.

I load the first table when the app starts. I ask for a readable database to load in members to display, and later I write to the database when the list changes. I’ve had no problems here.

The other two tables, however, I can’t get to work. The code in the helper classes is identical with the exception of class names and column names, and (at least until the point where I try to access the table) the code to use the table is nearly identical as well.

Here’s the code for my helper class (I’ve got a separate helper for each table, and as I said, it’s identical except for class names and columns):

public class db_MembersOpenHelper extends SQLiteOpenHelper
{
    public static final String TABLE_NAME = "members_table";
    public static final String[] COLUMN_NAMES = new String[] {
            Constants.KEY_ID,
            "name",
            "score"
    };
    private static final String TABLE_CREATE = "CREATE TABLE " + TABLE_NAME + " ("
            + COLUMN_NAMES[0] + " INTEGER PRIMARY KEY autoincrement, "
            + COLUMN_NAMES[1] + " TEXT, "
            + COLUMN_NAMES[2] + " INTEGER);";

    public db_MembersOpenHelper(Context context)
    {
        super(context, Constants.DATABASE_NAME, null, Constants.DATABASE_VERSION);
    }

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

    @Override
    public void  onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
        Log.w("TaskDBAdapter", "Upgrading from version " + oldVersion + " to " + newVersion + ".");
        // Do nothing. We do not have any updated DB version
    }
}

Here’s how I use it successfully:

db_MembersOpenHelper membersDbHelper = new db_MembersOpenHelper(this);
SQLiteDatabase membersDb = membersDbHelper.getReadableDatabase();
Cursor membersResult = membersDb.query(TABLE_NAME, null, null, null, null, null, null);
members = new HashMap<String, Integer>();

membersResult.moveToFirst();
for(int r = 0; r < membersResult.getCount(); r++)
{
    members.put(membersResult.getString(1), membersResult.getInt(2));
    membersResult.moveToNext();
}
membersDb.close();

And here’s where it fails:

db_PlayersOpenHelper playersDbHelper = new db_PlayersOpenHelper(this);
final SQLiteDatabase playersDb = playersDbHelper.getWritableDatabase();
if(newGame)
{
    for(String name : players)
    {
        ContentValues row = new ContentValues();
        row.put(COLUMN_NAMES[1], name);
        row.put(COLUMN_NAMES[2], (Integer)null);
        playersDb.insert(TABLE_NAME, null, row);
    }
}

The first one works like a charm. The second results in ERROR/Database(6739): Error inserting achievement_id=null name=c
android.database.sqlite.SQLiteException: no such table: players_table: , while compiling: INSERT INTO players_table(achievement_id, name) VALUES(?, ?);
...

I did do some testing, and the onCreate method is not being called at all for the tables that aren’t working. Which would explain why my phone thinks the table doesn’t exist, but I don’t know why the method isn’t getting called.

I can’t figure this out; what am I doing so wrong with the one table that I accidentally did right with the other?

  • 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-25T11:10:51+00:00Added an answer on May 25, 2026 at 11:10 am

    I think the problem is that you are managing three tables with with three helpers, but only using one database. SQLiteOpenHelper manages on database, not one table. For example, it checks to see whether the database, not table, exists when it starts. It already does, so onCreate() does not fire.

    I would manage all tables with one helper.

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

Sidebar

Related Questions

My app keeps track of the state of about 1000 objects. Those objects are
Our app (already deployed) is using an Access/Jet database. The upcoming version of our
App Engine recently announced support for Cross Group (XG) transactions ; one would expect
App Store We have been developing an app for quite some time now for
App store approval guideline says that Apps that send Push Notifications without first obtaining
My App needs to connect to and grab data from a MySQL database sitting
App Engine only allows you to use these formats for XMPP addresses: app-id@appspot.com anything@app-id.appspotchat.com
My app has many controls on its surface, and more are added dynamically at
An app I'm writing always crashes on a clients computer, but I don't get
My app is installed via NSIS. I want the installer to install the program

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.