How to delete a database

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

How to delete a database

Postby fugo » Wed Nov 26, 2008 6:00 pm

How do you delete a database programatically. I know that I can go to:

/data/data/<appdir>/databases

and blow away the database file. But how can I do it in code?
fugo
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Nov 26, 2008 5:53 pm

Top

Re: How to delete a database

Postby Sparkletron » Thu Jan 01, 2009 4:21 am

Just use a file reference like you would with any other Java app...

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. File databaseDirectory = new File("/data/data/<appdir>/databases/");
  2.  
  3. File[] databaseFiles = databaseDirectory.listFiles();
  4.  
  5.  
  6.  
  7. for (File databaseFile : databaseFiles) {
  8.  
  9.      databaseFile.delete();
  10.  
  11. }
  12.  
  13.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Sparkletron
Developer
Developer
 
Posts: 26
Joined: Tue Nov 04, 2008 6:17 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 9 guests