Delete ONE SPECIFIC table of a database - leave the rest intact
- by Jayomat
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