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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:40:00+00:00 2026-06-09T09:40:00+00:00

I have a problem considering SQLite insert. I have a class which stores 10

  • 0

I have a problem considering SQLite insert. I have a class which stores 10 different rows. These rows should then be inserted to the database when the user clicks a button, where there is a for-loop that goes 10 times and then it should be done. But im getting some weird errors.

I have used the same kind of SQLite code that I have used for other projects.

Using db:

           Log.v(LOG_TAG, "\n\n\nSave Clicked");
           for (int i = 0; i < 10; i++) {

            dataSpinner[i] = spinnerList.get(i).getSelectedItem().toString(); // Area
            dataExercise[i] = exerciseList.get(i).getText().toString(); // Exercise
            dataSet[i] = setList.get(i).getText().toString(); // Set
            dataRep[i] = repList.get(i).getText().toString(); // Rep

            // Info box
            // Might not need anything here?

            Log.v(LOG_SAVE,
                    i + ". area: " + dataSpinner[i].toString() + ", ex: "
                            + dataExercise[i].toString() + ", set:"
                            + dataSet[i].toString() + ", rep:"
                            + dataRep[i].toString());

            // Save the current row to db
            boolean diditWork = true;
            try {
                ScheduleDatabase entry = new ScheduleDatabase(Monday.this);
                entry.open();
                entry.createEntry(table, dataSpinner[i].toString(),
                        dataExercise[i].toString(), dataSet[i].toString(),
                        dataRep[i].toString());
                entry.close();
            } catch (Exception e) {
                diditWork = false;
                String error = e.toString();
                Toast.makeText(this, "Something went wrong, " + error,
                        Toast.LENGTH_SHORT);
            } finally {
                if (diditWork) {
                    Toast.makeText(this, "IT WORKED!!!!!!",
                            Toast.LENGTH_SHORT).show();
                }
            }
        }

Insert method in database class:

public long createEntry(String table, String area, String exercise,
        String set, String rep) throws SQLException {
    System.out.println("Values: " + table + ", " + area + ", " + exercise
            + ", " + set + ", " + rep);
    ContentValues cv = new ContentValues();
    cv.put(KEY_AREA, area);
    cv.put(KEY_EXERCISE, exercise);
    cv.put(KEY_SET, set);
    cv.put(KEY_REP, rep);
    System.out.println("Done putting");
    return ourDatabase.insert(table, null, cv);
}

And here is the error

(1) near "set": syntax error<br>
Error inserting exercise=Exercise: 19 area=Abdominals set=5 rep=10
android.database.sqlite.SQLiteException: near "set": syntax error (code 1): , while compiling: INSERT INTO monday(exercise,area,set,rep) VALUES (?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
at com.trainingschedule.days.ScheduleDatabase.createEntry(ScheduleDatabase.java:124)
at com.trainingschedule.days.Monday.onClick(Monday.java:262)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
  • 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-09T09:40:02+00:00Added an answer on June 9, 2026 at 9:40 am

    set is an SQLite keyword, change your column name to something else and your issue should go away.

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

Sidebar

Related Questions

i have following problem: I have a class Foo which encapsulates a web-api. the
For my website, I'm considering using Less . Can I have some problem of
what should be the best approach to make strings for different languages? I have
I have the following problem. I have to implement a class that has an
I have a problem that can essentially be viewed as a graph. I'm considering
I have an abstract class called Fruit. I then have a derived class called
I have a problem designing my database. I have to make a table witch
I would like to get a different solution to a problem I have solved
I have been considering the problems arising with user authentication, using sessions/cookies and the
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar

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.