[android-developers] Re: Drop entire database?
You have to think that the database is just a file in DDMS, so just call delete function passing directory as arg. On 6 abr, 16:22, gudujarlson wrote: > Thank you, Sirius, but my question was how to drop the entire > database, not just one table. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Drop entire database?
Thank you, Sirius, but my question was how to drop the entire database, not just one table. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Drop entire database?
Hi, You can drop the table by writing DROP TABLE tablename IF EXISTS But after that it is good to do a VACUUM (info about that in the link below). I.e the code might look like: private SQLiteDatabase db; private static final String TABLE_NAME = "name_of_table"; try{db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); db.execSQL("VACUUM");} catch(SQLException sqle){} Here is a good link to the SQLite documentation: http://www.sqlite.org/lang.html BR --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Drop entire database?
> The Context class has a suite of functions for creating, opening, and > deleting databases at the standard location of databases for your app. > > The SQLiteDatabase class can be used to access a databases at any absolute > path. In that case, you are using an absolute path, so use File to delete > the database file at that path. > > But unless you are putting your database on the SD card, you would be best > off using the Context methods for your database access. Ah ok, I think I get it now. I can just treat the database like a normal file. It wasn't obvious at first that I could "go under the covers" and manipulate the database via the filesystem API. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Drop entire database?
On Tue, Mar 24, 2009 at 10:53 PM, gudujarlson wrote: > The context class is not where I would expect to find the function to > delete a SQLite database. Wouldn't it be more intuitive to have this > function on the SQLiteDatabase class? The Context class has a suite of functions for creating, opening, and deleting databases at the standard location of databases for your app. The SQLiteDatabase class can be used to access a databases at any absolute path. In that case, you are using an absolute path, so use File to delete the database file at that path. But unless you are putting your database on the SD card, you would be best off using the Context methods for your database access. > > > On Mar 24, 11:24 pm, gudujarlson wrote: > > I have an automated test that creates a SQLite database. In the setup > > of the test I want to drop the database if it already exists. The > > problem is that I cannot find a function that deletes/drops a > > database. That seems like an odd omission. Help? > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Drop entire database?
I found the answer to my own question. http://developer.android.com/reference/android/content/Context.html#deleteDatabase(java.lang.String) The context class is not where I would expect to find the function to delete a SQLite database. Wouldn't it be more intuitive to have this function on the SQLiteDatabase class? On Mar 24, 11:24 pm, gudujarlson wrote: > I have an automated test that creates a SQLite database. In the setup > of the test I want to drop the database if it already exists. The > problem is that I cannot find a function that deletes/drops a > database. That seems like an odd omission. Help? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---