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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:26:58+00:00 2026-06-04T18:26:58+00:00

After running the code below my apps donot respond. Code seems correct to me

  • 0

After running the code below my apps donot respond. Code seems correct to me but
can’t understand what is wrong going on.

package com.navigationsystem;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase;
import android.hardware.SensorManager;
import android.util.Log;

public class DBAdapter {

    public static final String NODE_ID="nodeID";
    public static final String NODE_NAME="nodeName";
    public static final String VALUE1="value1";
    public static final String EDGE_ID="edgeID";
    public static final String TOTAL ="total";
    public static final String SOURCE_NODE_ID ="sourceNodeID";
    public static final String DESTINATION_NODE_ID ="destinationNodeID";

    private static final String TAG = "DBAdapter";
    private static final String DATABASE_NAME = "Graph";
    private static final String DATABASE_TABLE1 = "nodes";
    private static final String DATABASE_TABLE2 = "edges";
    private static final int DATABASE_VERSION = 1 ;

    private static final String DATABASE_CREATE ="create table nodes ( " 
        +"nodeID int PRIMARY KEY AUTO_INCREMENT NOT NULL," 
        +"nodeName varchar (20) NOT NULL," 
        +"value1 int NULL," 
        +"edgeID int NULL," 
        +"total int NOT NULL );"

        +"create table edges ( edgeID int PRIMARY KEY AUTO_INCREMENT," 
        +"sourceNodeID int NOT NULL ," 
        +"destinationNodeID int NOT NULL ," 
        +"value1 int NOT NULL );";


    private final Context context;
    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;

    public DBAdapter(Context ctx)
    {
        this.context = ctx;
        DBHelper = new DatabaseHelper(context);
    }

    private static class DatabaseHelper extends SQLiteOpenHelper
    {
        DatabaseHelper(Context context)
        {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db)
        {
            db.execSQL(DATABASE_CREATE);
        }
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion,int newVersion)
        {
            Log.w(TAG, "Upgrading database from version " + oldVersion
                    + " to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS titles");
            onCreate(db);
        }
    }

    public DBAdapter open() throws SQLException
    {
        db = DBHelper.getWritableDatabase();
        return this;
    }


    public void close()
    {
        DBHelper.close();
    }

    public long addEdges(String nodeName,String value1,String edgeID) throws SQLException
    {

        ContentValues cv = new ContentValues();
        cv.put(NODE_NAME, nodeName);
        cv.put(VALUE1, value1);
        cv.put(EDGE_ID, edgeID);
        return db.insert(DATABASE_TABLE1,null,cv);

    }


}

and database caller class is:

package com.navigationsystem;

import android.app.Activity;
import android.os.Bundle;


public class NavigationSystemActivity extends Activity
{

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);

        final DBAdapter db = new DBAdapter(this);
        db.open();
        db.addEdges("A","4","1");
        db.close();
    }
}

I want to store the value in database but neither table is created nor my app run.

please correct me what I am doing wrong .

thanks.

edit:logcat error

05-25 11:56:49.583: E/AndroidRuntime(9622): FATAL EXCEPTION: main
05-25 11:56:49.583: E/AndroidRuntime(9622): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.navigationsystem/com.navigationsystem.NavigationSystemActivity}: android.database.sqlite.SQLiteException: near "AUTO_INCREMENT": syntax error: , while compiling: create table nodes ( nodeID int PRIMARY KEY AUTO_INCREMENT NOT NULL,nodeName varchar (20) NOT NULL,value1 int NULL,edgeID int NULL,total int NOT NULL );
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.os.Looper.loop(Looper.java:137)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.app.ActivityThread.main(ActivityThread.java:4424)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at java.lang.reflect.Method.invokeNative(Native Method)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at java.lang.reflect.Method.invoke(Method.java:511)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at dalvik.system.NativeStart.main(Native Method)
05-25 11:56:49.583: E/AndroidRuntime(9622): Caused by: android.database.sqlite.SQLiteException: near "AUTO_INCREMENT": syntax error: , while compiling: create table nodes ( nodeID int PRIMARY KEY AUTO_INCREMENT NOT NULL,nodeName varchar (20) NOT NULL,value1 int NULL,edgeID int NULL,total int NOT NULL );
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:134)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteStatement.acquireAndLock(SQLiteStatement.java:260)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:84)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1899)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1839)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at com.navigationsystem.DBAdapter$DatabaseHelper.onCreate(DBAdapter.java:97)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:165)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at com.navigationsystem.DBAdapter.open(DBAdapter.java:112)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at com.navigationsystem.NavigationSystemActivity.onCreate(NavigationSystemActivity.java:18)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.app.Activity.performCreate(Activity.java:4465)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-25 11:56:49.583: E/AndroidRuntime(9622):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-25 11:56:49.583: E/AndroidRuntime(9622):     ... 11 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-04T18:27:00+00:00Added an answer on June 4, 2026 at 6:27 pm

    You’ve made a small syntax error. Change AUTO_INCREMENT to AUTOINCREMENT.


    Edit:

    You also mentioned that only one of your tables is getting created. This might be because you are trying to combine two creation statements into one. Try this instead:

    private static final String DATABASE_CREATE_1 = "CREATE TABLE NODES ( ... );";
    private static final String DATABASE_CREATE_2 = "CREATE TABLE EDGES ( ... );";
    

    and then in your onCreate method, call execSQL on each String:

    db.execSQL(DATABASE_CREATE_1);
    db.execSQL(DATABASE_CREATE_2);
    

    You will need to clear your existing database before the changes go into effect. Only after you do this will onCreate be called once again.

    Settings –> Applications –> [app name] –> Clear data

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

Sidebar

Related Questions

I wanted to generate a list view using below code. But after running this
I am getting an argument of length zero after running the code below. I
When running the below code, the app crashes (after ~30 seconds) with the below
After running the code below I get this output: Eve 1200 Could anyone explain
I have the code below. I would the for-each to stop running after the
The code below compiles but after clicking on first button it breaks with msg
Im trying to update the contents of an element after running some php code.
I have some Java code that is throwing out of memory exceptions after running
The offending block of code is below. The code almost always works, but sometimes
I'm running the code below and getting an empty chart using Flot/jQuery. Ideally what

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.