0

is there any simple way how to add column or update column via SQlite in Android?

Now I am using raw SQL:

public void addColumn(String tableName, String ColumnName, String ColumnType, String AdditionalDetails){
    SQLiteDatabase db=dtbhelper.getWritableDatabase();
    db.execSQL("ALTER TABLE "+tableName+" ADD COLUMN "+ColumnName+" "+ColumnType+" "+AdditionalDetails+";");
    Log.d("TAG","FINISHED");
}

THanks

1 Answer 1

1

Your query looks correct. In SQLite you only can ADD column and you cannot UPDATE it. Also refer to some restrictions when adding column.

Sign up to request clarification or add additional context in comments.

1 Comment

In my app I ended up with renaming old table and creating the new one. Though it's always possible to create new columns and not use old ones. As you can see SQLite by definition does not have options to delete or to update individual column.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.