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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:24:48+00:00 2026-06-16T09:24:48+00:00

When I try to open my database, the app just crashes. I’m posting the

  • 0

When I try to open my database, the app just crashes. I’m posting the code below but I have implemented another database in the same manner, in the same app and I’m having no problems with that.

public class projectdatabase {

public static final String KEY_ROWID = "_id";
public static final String PROJECT_NAME = "project_name";
public static final String PROJECT_ID = "project_id";
public static final String PROJECT_DIFFICULTY = "project_difficulty";
public static final String PROJECT_STATUS = "project_status";
public static final String PROJECT_START_DATE = "project_start_date";
public static final String PROJECT_FINISH_DATE = "project_finsish_date";

private static final String DATABASE_NAME = "project_db";
private static final String DATABASE_TABLE = "project_details";
private static final int DATABASE_VERSION = 1;

private DbHelper ourHelper;
private final Context projectdbContext;
private SQLiteDatabase projectDatabase;

private static class DbHelper extends SQLiteOpenHelper {
    public DbHelper(Context context) {

        super(context, DATABASE_NAME, null, DATABASE_VERSION);

    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub

        db.execSQL("CREATE TABLE "+ DATABASE_TABLE + " (" +
                KEY_ROWID + " INTEGER AUTOINCREMENT," +
                PROJECT_NAME + " TEXT NOT NULL," +
                PROJECT_ID + " INTEGER PRIMARY KEY," +
                PROJECT_START_DATE + " TEXT," +
                PROJECT_FINISH_DATE + " TEXT," +
                PROJECT_DIFFICULTY + " TEXT, " +
                PROJECT_STATUS + " TEXT);"
               ); 

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub

        db.execSQL("DROP TABLE IF EXIST " + DATABASE_NAME);
        onCreate(db);

    }
}

public projectdatabase (Context c) {                            
     projectdbContext = c;
}

public projectdatabase open() {                                                 //Open database
    ourHelper = new DbHelper(projectdbContext);
    projectDatabase = ourHelper.getWritableDatabase();
    return this;
}

Here is the Logcat:
(I have made that part in bold which I think highlights the main problem)

12-27 01:22:21.893: E/AndroidRuntime(2214): FATAL EXCEPTION: main
12-27 01:22:21.893: E/AndroidRuntime(2214): java.lang.IllegalStateException: Could not execute method of the activity
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.view.View$1.onClick(View.java:3044)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.view.View.performClick(View.java:3511)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.view.View$PerformClick.run(View.java:14105)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.os.Handler.handleCallback(Handler.java:605)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.os.Looper.loop(Looper.java:137)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.app.ActivityThread.main(ActivityThread.java:4424)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at java.lang.reflect.Method.invokeNative(Native Method)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at java.lang.reflect.Method.invoke(Method.java:511)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at dalvik.system.NativeStart.main(Native Method)
12-27 01:22:21.893: E/AndroidRuntime(2214): Caused by: java.lang.reflect.InvocationTargetException
12-27 01:22:21.893: E/AndroidRuntime(2214):     at java.lang.reflect.Method.invokeNative(Native Method)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at java.lang.reflect.Method.invoke(Method.java:511)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.view.View$1.onClick(View.java:3039)
12-27 01:22:21.893: E/AndroidRuntime(2214):     ... 11 more
**12-27 01:22:21.893: E/AndroidRuntime(2214): Caused by: android.database.sqlite.SQLiteException: near "AUTOINCREMENT": syntax error: , while compiling: CREATE TABLE project_details (_id INTEGER AUTOINCREMENT,project_name TEXT NOT NULL,project_id INTEGER PRIMARY KEY,project_start_date TEXT,project_finsish_date TEXT,project_difficulty TEXT, project_status TEXT);**
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:134)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteStatement.acquireAndLock(SQLiteStatement.java:260)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:84)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1899)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1839)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at com.kk.project.projectdatabase$DbHelper.onCreate(projectdatabase.java:38)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:165)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at com.kk.project.projectdatabase.open(projectdatabase.java:66)
12-27 01:22:21.893: E/AndroidRuntime(2214):     at com.kk.project.Addproject.submit_project(Addproject.java:112)
12-27 01:22:21.893: E/AndroidRuntime(2214):     ... 14 more
  • 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-16T09:24:49+00:00Added an answer on June 16, 2026 at 9:24 am

    You cannot use AUTOINCREMENT on a column that is not the PRIMARY KEY.

    However you can use a nested SELECT statement or create your own trigger to do the same thing. Please read: SQLite auto-increment non-primary key field

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

Sidebar

Related Questions

I try to open a finder window which works fine but every time I
When I try to open a file in write mode with the following code:
Whenever I try to open a file with ifstream, it compiles fine, but will
I have a problem here. My app saves some objects into a SQLite database
I am trying to insert data into a database but I have it seems
I've got this database taken from assets folder, but i can't open it in
I have an iPad app that is using a sqlite database using FMDB as
When I try to open a database in the assets folder with the method
I try open and play .wav files with NAudio lib. private OpenFileDialog openFileDialog =
when I try to open a file for reading in my console application i

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.