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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:45:04+00:00 2026-05-26T01:45:04+00:00

public static final String MYDATABASE_NAME = MY_DATABASE; public static final String MYDATABASE_TABLE = MY_TABLE;

  • 0
 public static final String MYDATABASE_NAME = "MY_DATABASE";
 public static final String MYDATABASE_TABLE = "MY_TABLE";
 public static final String MYDATABASE_TABLE2 = "MY_TABLE2";
 public static final int MYDATABASE_VERSION = 1;
 public static final String KEY_ID = "_id";
 public static final String KEY_ID2 = "_id2";
 public static final String KEY_CONTENT1 = "Content1";
 public static final String KEY_CONTENT2 = "Content2";
 public static final String KEY_CONTENT3 = "Content3";

 //create table MY_DATABASE (ID integer primary key, Content text not null);
 private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" 
                                                        +KEY_ID + " integer primary key autoincrement, " 
                                                        + KEY_CONTENT1 + " text not null);";

 private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" 
                                                        + KEY_ID2 + " integer autoincrement, " 
                                                        + KEY_CONTENT2 + " text not null, " 
                                                        + KEY_CONTENT3 + " text not null, "
                                                        + " FOREIGN KEY ("+KEY_ID2+") REFERENCES "+MYDATABASE_TABLE+" ("+KEY_ID+"));";

I can not find out what gives the following error, please help me out thank you.

09-29 13:41:19.760: ERROR/Database(334): Failure 1 (near
“autoincrement”: syntax error) on 0x218df0 when preparing ‘create
table MY_TABLE2 (_id2 integer autoincrement, Content2 text not null,
Content3 text not null, FOREIGN KEY (_id2) REFERENCES MY_TABLE
(_id));’.

09-29 13:41:19.770: DEBUG/AndroidRuntime(334): Shutting down VM

09-29 13:41:19.770: WARN/dalvikvm(334): threadid=1: thread exiting
with uncaught exception (group=0x4001d800)

09-29 13:41:19.791: ERROR/AndroidRuntime(334): FATAL EXCEPTION: main

09-29 13:41:19.791: ERROR/AndroidRuntime(334):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{sep.com/sep.com.SepActivity}:
android.database.sqlite.SQLiteException: near “autoincrement”: syntax
error: create table MY_TABLE2 (_id2 integer autoincrement, Content2
text not null, Content3 text not null, FOREIGN KEY (_id2) REFERENCES
MY_TABLE (_id));

  • 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-26T01:45:05+00:00Added an answer on May 26, 2026 at 1:45 am

    In short: In SQLite a column declared INTEGER PRIMARY KEY will autoincrement. There is no autoincrement keyword in SQLite, that is why you are getting an error.

    You can find out more on SQLite FAQ.

    EDIT: just writing integer primary key it is enough. SQLite will automatically increment your ids.

    EDIT2: Your onUpgrade() method should look like this :

      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            if (newVersion > oldVersion) {
                Log.w("MyAppTag","Updating database from version " + oldVersion + " to "
                        + newVersion + " .Existing data will be lost.");
                db.execSQL("DROP TABLE IF EXISTS " + MY_TABLE);
                db.execSQL("DROP TABLE IF EXISTS " + MY_TABLE2);
                onCreate(db);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this case: public Class1 { public static final String ONE = ABC; public
I have a String[] with values like so: public static final String[] VALUES =
considering this example: public static void main(final String[] args) { final List<String> myList =
Lets assume following classes definition: public class A { public final static String SOME_VALUE;
I've seen examples like this: public class MaxSeconds { public static final int MAX_SECONDS
Say I have a class: public class R { public static final int _1st
public static final String REGEX_ADDRESS_ZIP = ^[0-9\\ -.]+$; The above regex for validating zip
Here are my constants //Encryption fields /** Algorithm=RSA Mode=ECB Padding=PKCS1Padding*/ public static final String
When you establish a shared preference such as below... public static final String PREFS_HI
public static final String readURL(String url)throws Throwable { try { InputStream in = (InputStream)

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.