Delete ONE SPECIFIC table of a database - leave the rest intact

Posted by Jayomat on Stack Overflow See other posts from Stack Overflow or by Jayomat
Published on 2010-04-23T11:33:34Z Indexed on 2010/04/23 11:53 UTC
Read the original article Hit count: 291

Filed under:
|
|
|

Hi, I have a database where I store two different kinds of data. One table is for favorite routes, the other stores the retrieved routes from a server.

I can retrieve the routes etc just fine. But after retrieving the first Route, pressing back or HOME, and then retrieving another route, the routes table is filled with all the old routes plus the new ones.

So my question: how do I delete ONLY the routes table and not the whole database because I don't want to delete the added favorites....?!

I found the following function in the android docs:

public int delete (String table, String whereClause, String[] whereArgs)

and I tried to implement it, but I must pass a SQLiteDataBase as an argument. But how?

I implemented:

public void deleteTableRoutes(SQLiteDataBase db){
  db.delete("routes", null, null);
}

But I want to call this function from a different class where I have no reference to the database.. so what do I have to pass as an argument? Or how do I get a reference to my database?

I build my database upon the code example of the NotePadExample from the dev docs.

How to solve this problem? thanks

© Stack Overflow or respective owner

Related posts about android

Related posts about database