How do I update tables in the Android onupgrade SQLiteDataba

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

How do I update tables in the Android onupgrade SQLiteDataba

Postby practicallysimplesoftware » Thu May 30, 2013 6:11 pm

I am having issues getting the update to work in the onUpgrade event in the SQLiteDatabase event for an android application. The data is not getting updated after executing the SQL update when onUpgrade is called.

The problem that I'm having is that the data is not being updated. After running the application, I am still seeing the old data that was there before the update statement was executed. I am trying to replace the 'REPLACEMENT CHARACTER' (being seen as a black diamond with a white question mark in it) with an apostrophe.

I didn't get any errors in the LogCat when the SQL was executed.

I did previously verify that the SQL works using the sqlite3 command line tool through adb shell.

Below is the code that I am trying to execute, running the application in the emulator.

Code: Select all
String strSpecChar = DatabaseUtils.sqlEscapeString("�");
    String strSpecCharFilter = DatabaseUtils.sqlEscapeString("%∩┐╜%");
    String strReplChar = DatabaseUtils.sqlEscapeString("'");
    String strCharReplace = "UPDATE "
      + myTable + " SET "
      + column2 + " = REPLACE(" + column2 + ", "
                                + strSpecChar + ", "
                                + strReplChar + ")"
      + " WHERE " + column2 + " LIKE " + strSpecCharFilter;

The log value of strCharReplace:

Code: Select all
strCharReplace = "UPDATE table SET column2 = REPLACE(payeename, '�', '''') WHERE column2 LIKE '%�%'"

I re-upload the database to the emulator with each run in order to get the code in the 'onUpgrade' method to run, because I am upgrading from database version 1 to 2.

I have been looking online for a few days trying to get this to work, and without success far, I have searched online, used the debugger, and I also verified that the code above works through the sqlite3 adb shell command line interface before posting my question.

Thanks in advance for any help or advice on this.
Once Poster
Once Poster
Posts: 1
Joined: Thu May 30, 2013 5:31 pm


Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests