0

I have an online page where I put SQLite queries and then on my Android app I iterate through them and execute them.. Here is the code:

        URL url;
        try {
            url = new URL(Database.UpdateDB_URL);

            URLConnection connection = url.openConnection();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line = null;
            File dbfile = new File(Database.Database_PATH);

            SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);

            while ((line = reader.readLine()) != null)
                db.rawQuery(line.trim(), null);
            db.close();
            reader.close();

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Here is an example of whats in line.trim() when the while loop is being run:

UPDATE Behavior SET Body="AAAAAA" WHERE _id=1

but when I browse the database in my phone I see that nothing's changed, but if I run this exact query on my pc, it works!
Why is that?

keyser
  • 18,829
  • 16
  • 59
  • 101
Omar
  • 7,835
  • 14
  • 62
  • 108
  • 1
    why do you send the query over the internet? why not use some sort of API mechanism and build the query on device? – ariefbayu Oct 14 '12 at 09:05
  • I ship my app with a DB and I need to update some data in it from time to time.. – Omar Oct 14 '12 at 09:08

2 Answers2

0

For Update Sqlite Use database.update() Query.

ariefbayu
  • 21,849
  • 12
  • 71
  • 92
Md Abdul Gafur
  • 6,213
  • 2
  • 27
  • 37
0

With the help of THIS thread, it worked out.. You just have to add the cursor object, moveToFirst, and then close it..

Community
  • 1
  • 1
Omar
  • 7,835
  • 14
  • 62
  • 108