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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:08:47+00:00 2026-06-13T00:08:47+00:00

I’ve been getting this error ever since i added a new table to my

  • 0

I’ve been getting this error ever since i added a new table to my database, don’t know why. I’ve done this methos a few time and there were no errors encountered but now this happens, sqlite are like women you do something for the first time and everything seems ok but when you do the same thing again they just start to get crazy for some reason.

anyway here’s some relevant code:

protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.selectorcreatemove);

        allFunctions();

    }

    private void allFunctions() {
        addMove = (Button) findViewById(R.id.bAddMove);
        etAddMove = (EditText) findViewById(R.id.etMoveName);

        MoveList = (ListView) findViewById(R.id.lvMoveItems);
        SQLHandlerview = new SQLHandler(this);

        SQLHandlerview = new SQLHandler(ListMovingNames.this);
        SQLHandlerview.open();

        cursor = SQLHandlerview.getMove();
        startManagingCursor(cursor);

        String[] from = new String[]{SQLHandler.KEY_MOVENAME};
        int[] to = new int[]{R.id.text};

        SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
        MoveList.setAdapter(cursorAdapter);

        addMove.setOnClickListener(new OnClickListener() {

            @SuppressLint("NewApi")
            public void onClick(View v) {
                // TODO Auto-generated method stub

            }
        });

        MoveList.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView<?> arg0, final View view, int position,
                    long id) {
                // TODO Auto-generated method stub
                AlertDialog load = new AlertDialog.Builder(ListMovingNames.this).show();
                load.setContentView(R.layout.load);
                move = ((TextView) view).getText().toString();
                Intent i = new Intent(getApplicationContext(), StartMoving.class);
                i.putExtra("moveName", move);
                startActivity(i);               
            }
        });

        etAddMove.setOnKeyListener(new OnKeyListener() {

            @SuppressLint("NewApi")
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                // TODO Auto-generated method stub
                if ( (event.getAction() == KeyEvent.ACTION_DOWN  ) && (keyCode== KeyEvent.KEYCODE_ENTER)   )
                {               
                    String ssmoveName = etAddMove.getText().toString();
                    int x = ssmoveName.length() - 1;
                    if (ssmoveName.equals("") || Character.isWhitespace(ssmoveName.charAt(0)) || Character.isWhitespace(ssmoveName.charAt(x))) {
                        Toast.makeText(ListMovingNames.this, 
                                "Please enter a valid name! Avoid giving a blank name or white space at the beginning or end of the name", 
                                Toast.LENGTH_LONG).show();
                    }else{
                        try {
                            String scheck = SQLHandlerview.checkMove(ssmoveName);
                            if (scheck.equals(ssmoveName)) {
                                Toast.makeText(ListMovingNames.this, "Move name already exist please give a different name", Toast.LENGTH_LONG).show();
                            } else{
                                AlertDialog load = new AlertDialog.Builder(ListMovingNames.this).show();
                                load.setContentView(R.layout.load);
                                SQLHandlerview.createMove(ssmoveName);
                                SQLHandlerview.createList();
                                SQLHandlerview.setTodo(ssmoveName);
                                Intent i = new Intent(getApplicationContext(), StartMoving.class);
                                i.putExtra("moveName", ssmoveName);
                                startActivity(i);
                            }
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            AlertDialog load = new AlertDialog.Builder(ListMovingNames.this).show();
                            load.setContentView(R.layout.load);
                            SQLHandlerview.createMove(ssmoveName);
                            SQLHandlerview.createList();
                            SQLHandlerview.setTodo(ssmoveName);
                            Intent i = new Intent(getApplicationContext(), StartMoving.class);
                            i.putExtra("moveName", ssmoveName);
                            startActivity(i);
                        }
                    }
                    return true;
                }
                return false;
            }
        });

    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        allFunctions();
        SQLHandlerview.open();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }

    @Override
    protected void onDestroy(){
        super.onDestroy();
        if (SQLHandlerview != null) {
            SQLHandlerview.close();
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)  {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            // do something on back.

            Intent i = new Intent(ListMovingNames.this, MainActivity.class);
            i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(i);
            return true;
        }

        return super.onKeyDown(keyCode, event);
    }

}

and here’s the sql handler

public class SQLHandler {

    public static final String KEY_MOVENAME = "movename";
    public static final String KEY_ID1 = "_id";
    public static final String KEY_ID5 = "_id";

    public static final String KEY_MOVEDATE = "movedate";
    public static final String KEY_TOTALMOVEWEIGHT = "totalmoveweight";
    public static final String KEY_TOTALITEM = "totalitem";

    private static final String DATABASE_NAME = "mymovingfriend";
    private static final int DATABASE_VERSION = 1;

    public static final String KEY_LISTITEMNAME = "listitemname";
    public static final String KEY_LISTITEMWEIGHT = "listitemweight";
    public static final String KEY_LISTITEMROOM = "listitemroom";

    private static final String DATABASE_TABLE1 = "movingname";
    private static final String DATABASE_TABLE5 = "lisitem";

    public static final String CREATE_TABLE_1 = "CREATE TABLE " + DATABASE_TABLE1 + " (" + 
            KEY_ID1 + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
            KEY_MOVEDATE + " TEXT NOT NULL, " + 
            KEY_TOTALMOVEWEIGHT + " TEXT NOT NULL, " + 
            KEY_TOTALITEM + " INTEGER NOT NULL, " +
            KEY_MOVENAME + " TEXT NOT NULL);";

    public static final String CREATE_TABLE_5 = "CREATE TABLE " + DATABASE_TABLE5 + " (" + 
            KEY_ID5 + " INTEGER PRIMARY KEY AUTOINCREMENT," + 
            KEY_LISTITEMNAME + " TEXT NOT NULL, " + 
            KEY_LISTITEMWEIGHT + " TEXT NOT NULL, " +
            KEY_LISTITEMROOM + " TEXT NOT NULL);";

    private DbHelper ourHelper;
    private final Context ourContext;
    private SQLiteDatabase ourDatabase;

    private static class DbHelper extends SQLiteOpenHelper{

        public DbHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub
            db.execSQL(CREATE_TABLE_1);
            db.execSQL(CREATE_TABLE_5);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldversion, int newversion) {
            // TODO Auto-generated method stub
            db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE1);
            db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE5);
            onCreate(db);
        }
    }

    public SQLHandler(Context c){
        ourContext = c;
    }

    public SQLHandler open() throws SQLException{
        ourHelper = new DbHelper(ourContext);
        ourDatabase = ourHelper.getWritableDatabase();
        return this;
    }

    public void close(){
        ourDatabase.close();
        ourHelper.close();
    }

    public long createMove(String smovename){
        ContentValues cv = new ContentValues();
        cv.put(KEY_MOVENAME, smovename);
        cv.put(KEY_MOVEDATE, "Not yet set");
        cv.put(KEY_TOTALMOVEWEIGHT, "0");
        cv.put(KEY_TOTALITEM, 0);
        return ourDatabase.insert(DATABASE_TABLE1, null, cv);
    }

    public void createList(){
        ContentValues cv = new ContentValues();

        String[] sroom = new String[]{"Kitchen", "Bedroom", "Dinning Room"};
        String[] sitem = new String[]{"Dishwasher", "Bed", "Table"};
        String[] sweight = new String[]{"40", "25", "15"};

        for (int i = 0; i < sroom.length; i++) {
            cv.put(KEY_LISTITEMROOM, sroom[i]);
            cv.put(KEY_LISTITEMNAME, sitem[i]);
            cv.put(KEY_LISTITEMWEIGHT, sweight[i]);
            ourDatabase.insert(DATABASE_TABLE5, null, cv);
        }
    }

    public ArrayList<String> getitems(){
        String[] columns = new String[]{KEY_ID5, KEY_ITEMNAME};
        Cursor c = ourDatabase.query(DATABASE_TABLE5, columns, null, null, null, null, null);
        ArrayList<String> items = new ArrayList<String>();

        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
            items.add(c.getString(1));
        }

        return items;
    }

    public ArrayList<String> getitemweight(){
        String[] columns = new String[]{KEY_ID5, KEY_ITEMWEIGHT};
        Cursor c = ourDatabase.query(DATABASE_TABLE5, columns, null, null, null, null, null);
        ArrayList<String> items = new ArrayList<String>();

        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
            items.add(c.getString(1));
        }

        return items;
    }

    public ArrayList<String> getitemclass(){
        String[] columns = new String[]{KEY_ID5, KEY_LISTITEMROOM};
        Cursor c = ourDatabase.query(DATABASE_TABLE5, columns, null, null, null, null, null);
        ArrayList<String> items = new ArrayList<String>();

        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
            items.add(c.getString(1));
        }

        return items;
    }

}
  • 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-13T00:08:48+00:00Added an answer on June 13, 2026 at 12:08 am

    private static final int DATABASE_VERSION = 1;

    This value is still equal to 1. I’m assuming that is the value you used when the database was created. onCreate() is only called the first time that DbHelper is called on the device. onUpgrade won’t be called unless the value of DATABASE_VERSION is changed. This means that your new table was never actually created in the database.

    Try setting DATABASE_VERSION = 2.

    ——EDIT—–

    There appears to be a typo in the value of DATABASE_TABLE5.

    private static final String DATABASE_TABLE5 = “lisitem”;

    —-for loops will fail if query returns 0 results—–

    use:

    if(c.moveToFirst()){

    do{
        items.add(c.getString(1);
        c.moveToNext();
    }while(!c.isAfterLast());
    

    }

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported

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.