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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:26:54+00:00 2026-06-14T19:26:54+00:00

I am new to SQLite and am trying to go about creating a basic

  • 0

I am new to SQLite and am trying to go about creating a basic database for learning purposes.

In my Main I declare a new DbHelper and SQLiteDatabase..

    // Open Database
    DbHelper dbHelper = new DbHelper(Main.this);        
    SQLiteDatabase db = dbHelper.getWritableDatabase();

My DbHelper class..

public class DbHelper extends SQLiteOpenHelper
{
private static final String TAG = "DbHelper";

public static final String DB_NAME = "exerciseDB";
public static final int DB_VERSION = 1; // User defined - up to you
public static final String TABLE = "Exercises";

// Try keep column names consistent with object names
public static final String C_ID = "_id"; // "_id" special
public static final String C_PARENTEXERCISE = "parentExercise";
public static final String C_SETNO = "setNo";
public static final String C_REPSANDWEIGHT = "repsAndWeight";

public String sql;

Context context;

public DbHelper(Context context)
{
    super(context, DB_NAME, null, DB_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db)
{
    // SQL commands
    sql = String.format(
            "CREATE TABLE %s (%s INT PRIMARY KEY %s TEXT %s INT %s TEXT);",
            TABLE, C_ID, C_PARENTEXERCISE, C_SETNO, C_REPSANDWEIGHT);

    // Prints out sql String to Logcat
    Log.d(TAG, "onCreate sql: " + sql);

    db.execSQL(sql); // Executes the SQL commands
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
    // Maintain users data first
    db.execSQL("drop table if exists " + TABLE); // Deletes table if it
                                                    // exists

    Log.d(TAG, "onUpdata dropped table" + TABLE);

    // Recreate database
    this.onCreate(db);
}

public String getSQLcmd()
{
    return sql;     
}

}

The LogCat output of the sql command is as I believe it should be..

onCreate sql: CREATE TABLE Exercises (_id INT PRIMARY KEY parentExercise TEXT setNo INT repsAndWeight TEXT);

LogCat also says:

 11-10 17:44:14.702: E/SQLiteLog(13053): (1) near "parentExercise": syntax error

But I can’t seem to see anything wrong with anything parentExercise related.

Any help would be greatly appreciated.

Cheers.

  • 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-14T19:26:55+00:00Added an answer on June 14, 2026 at 7:26 pm

    your query should look like

    CREATE TABLE Exercises (_id INT PRIMARY KEY, parentExercise TEXT, setNo INT, repsAndWeight TEXT)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New in sqlite and terminal commands,so may be this is simple.I was trying to
Greetings All, I have a SQLite database that I'm trying to add a new
I am new to using SQLite databases and android mobile development. I am trying
I'm new to Android and SQLite, too. I'm trying to write a method where
I am working on making a new SQLite database. Obviously for a number of
What is the difference between: $db = new SQLiteDatabase('name.db'); and $db = new PDO('sqlite:name.db');
I am new to using the SQLite database in iphone apps. I have created
I'm new to android apps development and I have a basic sqlite question. What
i'm new to Microsoft Sync Framework and trying to synchronise an sqlite db with
I am trying to connect to a Sqlite database with Windows phone 7. But

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.