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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:27:36+00:00 2026-06-16T18:27:36+00:00

I am trying to hardcode a single row into my SQLite database. I want

  • 0

I am trying to hardcode a single row into my SQLite database. I want to know if this will work or, if I should do something different? I want to continue using my content values, because I have so much code written with my content values.

public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL("CREATE TABLE " + DB_TBL + " (" +
                KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
                KEY_LEVEL + " INTEGER NOT NULL, " + 
                KEY_HEALTH + " INTEGER NOT NULL, " +
                KEY_NAME + " TEXT NOT NULL, " +
                KEY_CRIT + " INTEGER NOT NULL, " +
                KEY_CRIT_RANGE + " INTEGER NOT NULL, " +
                KEY_CRIT_INC + " INTEGER NOT NULL, " +
                KEY_HIT_RANGE + " INTEGER NOT NULL, " +
                KEY_HIT_INC + " INTEGER NOT NULL, " +
                KEY_CHAR_IMG + " INTEGER NOT NULL, " +
                KEY_TOTAL_XP + " INTEGER NOT NULL, " +
                KEY_XP + " INTEGER NOT NULL, " +
                KEY_XP_NEEDED + " INTEGER NOT NULL, " +
                KEY_COINS + " INTEGER NOT NULL, " + 
                KEY_SMALL_POTS + " INTEGER NOT NULL, " +
                KEY_LARGE_POTS + " INTEGER NOT NULL)"
            );
        DbHelper helper = new DbHelper();//I have to put a context in the argument 
        SQLiteDatabase database = helper.getWritableDatabase();//but I don't know what to put or if I'm doing it right
         values = new ContentValues();
            values.put(KEY_NAME, "User1");
            values.put( KEY_LEVEL, 1);
            values.put(KEY_HEALTH, 10);
            values.put(KEY_CRIT, 5);
            values.put(KEY_CRIT_RANGE, 2);
            values.put(KEY_CRIT_INC, 2);
            values.put(KEY_HIT_RANGE, 2);
            values.put(KEY_HIT_INC, 0);
            values.put(KEY_TOTAL_XP, 0);
            values.put(KEY_XP, 0);
            values.put(KEY_XP_NEEDED, 25);
            values.put(KEY_COINS, 5);
            values.put(KEY_SMALL_POTS, 0);
            values.put(KEY_LARGE_POTS, 0);
            values.put(KEY_CHAR_IMG, 1);
            database.insert(DB_TBL,  null, values);

    }

logcat

01-04 12:36:06.403: W/dalvikvm(18454): threadid=11: thread exiting with uncaught exception (group=0x40aa3228)
01-04 12:36:06.473: E/AndroidRuntime(18454): FATAL EXCEPTION: UpdateThread
01-04 12:36:06.473: E/AndroidRuntime(18454): java.lang.StackOverflowError
01-04 12:36:06.473: E/AndroidRuntime(18454):    at android.database.sqlite.SQLiteOpenHelper.<init>(SQLiteOpenHelper.java:77)
01-04 12:36:06.473: E/AndroidRuntime(18454):    at com.tanukiproductions.battleforchristmas.SQLiteTable$DbHelper.<init>(SQLiteTable.java:45)
01-04 12:36:06.473: E/AndroidRuntime(18454):    at com.tanukiproductions.battleforchristmas.SQLiteTable$DbHelper.<init>(SQLiteTable.java:46)
  • 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-16T18:27:37+00:00Added an answer on June 16, 2026 at 6:27 pm

    I want to know if this will work or, if I should do something different?

    That will work, as long as ourDatabase references db. But the best way to test it is to try it yourself.

    As a note, you are putting integers into text columns. While this is not an error in SQLite because of type affinity, it doesn’t really make sense and you might have trouble when you try to sort those columns numerically. You should declare them as INTEGER.

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

Sidebar

Related Questions

I'm trying to hardcode a function as string, turn it into a function and
I'm trying to write a utility function that will open three different types of
I'm trying to write a generic metaclass to track subclasses Since I want this
I don't want to hardcode the name of a Weka classifier into my Java
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to figure out how I can do this properly. The print_r looks like
Trying to copy the msdn refernce here doesn't work and gives an error I
Trying to implement LoaderManager + CursorLoader. In onFinish method adapter should swap its cursor
trying to figure out why this is happening - I have an input text
I am trying to select a table within my database with a GET Method.

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.