Caused by: android.database.sqlite.SQLiteException: Can't upgrade read-only database from version -


can not figure 1 out. i'm upgrading database , i've created function rename column renaming original table temp table , creating new table renamed field, copy data temp table new table, it's failing when getting part of copying data.

function performing rename:

public void modifycolumn(sqlitedatabase db, string oldcolumnname, string newcolumnname, string[] newcolumnconstraints) {      // current table columns     string sql = string.format("pragma table_info('%s')", table_name);     cursor cursor = db.rawquery(sql, new string[] {});      int length = cursor.getcount();     string[] oc = new string[length], nc = new string[length], c = new string[length];      while(cursor.movetonext()){         int cid = cursor.getint(cursor.getcolumnindex("cid"));         string name = cursor.getstring(cursor.getcolumnindex("name"));         string type = cursor.getstring(cursor.getcolumnindex("type"));         int notnull = cursor.getint(cursor.getcolumnindex("notnull"));         string dflt = cursor.getstring(cursor.getcolumnindex("dflt_value"));         int pk = cursor.getint(cursor.getcolumnindex("pk"));          vector<string> constraints = new vector<string>();          // add data type field         constraints.add(type);          // add primary key option field         if(pk > 0)             constraints.add("primary key");          // add not null option field         if(notnull > 0)             constraints.add("not null");          // add default value field         if(dflt != null)             constraints.add("default " + dflt);          string cname = name;         string ctype = textutils.join(" ", constraints.toarray());          oc[cid] = cname;         cname = (cname.equals(oldcolumnname))? newcolumnname : cname;         nc[cid] = cname;          if(newcolumnconstraints != null)             ctype = textutils.join(" ", newcolumnconstraints);          c[cid] = cname + " " + ctype;     }       // rename old table     this.renametable(db, "tmp_" + table_name);      // create new table modified column     this.createtable(db, table_name, c);      // copy data temporary table new table     sql = "insert " + table_name + " (" + textutils.join(", ", nc) +              ") select (" + textutils.join(", ", oc) + ") tmp_" + table_name;     db.execsql(sql);      // drop temporary table     db.execsql("drop table tmp_" + table_name); } 

at "copy data temporary table new table" comment, sql before being executed looks like:

insert vehicles (_id, vlabel, vyear, vmake, vmodel, voption, vdetail, vadded) select (id, vlabel, vyear, vmake, vmodel, voption, vdetail, vadded) tmp_vehicles 

then following error output:

06-08 19:33:05.888: e/database(21562): failure 1 (near ",": syntax error) on 0x2037d8 when preparing 'insert vehicles (_id, vlabel, vyear, vmake, vmodel, voption, vdetail, vadded) select (id, vlabel, vyear, vmake, vmodel, voption, vdetail, vadded) tmp_vehicles'. 06-08 19:33:08.711: w/dalvikvm(21562): threadid=1: thread exiting uncaught exception (group=0x4001f560) 06-08 19:33:08.771: e/androidruntime(21562): fatal exception: main 06-08 19:33:08.771: e/androidruntime(21562): java.lang.runtimeexception: unable start activity  06-08 19:33:08.771: e/androidruntime(21562):    @ android.app.activitythread.performlaunchactivity(activitythread.java:1648) 06-08 19:33:08.771: e/androidruntime(21562):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:1662) 06-08 19:33:08.771: e/androidruntime(21562):    @ android.app.activitythread.access$1500(activitythread.java:117) 06-08 19:33:08.771: e/androidruntime(21562):    @ android.app.activitythread$h.handlemessage(activitythread.java:931) 06-08 19:33:08.771: e/androidruntime(21562):    @ android.os.handler.dispatchmessage(handler.java:99) 06-08 19:33:08.771: e/androidruntime(21562):    @ android.os.looper.loop(looper.java:130) 06-08 19:33:08.771: e/androidruntime(21562):    @ android.app.activitythread.main(activitythread.java:3696) 06-08 19:33:08.771: e/androidruntime(21562):    @ java.lang.reflect.method.invokenative(native method) 06-08 19:33:08.771: e/androidruntime(21562):    @ java.lang.reflect.method.invoke(method.java:507) 06-08 19:33:08.771: e/androidruntime(21562):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:866) 06-08 19:33:08.771: e/androidruntime(21562):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:624) 06-08 19:33:08.771: e/androidruntime(21562):    @ dalvik.system.nativestart.main(native method) 

the select syntax wrong.

replace

select (column1, column2, ...) 

with

select column1, column2, ... 

i.e. remove parentheses.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -