0

i am using the below code to insert row to my db. every thing is fine but this method does not save row to the db.
what is wrong with this code :

public void insert(Restaurant rest) {

    String[] args = { String.valueOf(rest.getId()), rest.getName(),
            rest.getDescription(), rest.getAddress(), rest.getTel1(),
            rest.getTel2(), rest.getTel3(), rest.getEmail(),
            String.valueOf(rest.getCategory()),
            String.valueOf(rest.getRegion()) };
    m_db.rawQuery(
            "INSERT OR REPLACE INTO restaurant(id,name,description,address,tel1,tel2,tel3,email,category,region) VALUES(?,?,?,?,?,?,?,?,?,?)",
            args);
}
ReZa
  • 1,273
  • 2
  • 18
  • 33

1 Answers1

2

Use execSQL() and not rawQuery() for raw SQL that modifies the database.

rawQuery() alone won't execute the SQL; you'd need to call one of the moveTo...() methods on the returned Cursor to execute it.

laalto
  • 150,114
  • 66
  • 286
  • 303
  • Worked for me! Thank. @laalto Please, do you think you could help me with this question http://stackoverflow.com/questions/25598696/recommended-way-order-to-read-data-from-a-webservice-parse-that-data-and-inse – Axel Sep 01 '14 at 23:06