Code sample: Deleting an SQLite database

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.database.*;
import net.rim.device.api.io.*;

public class DeleteDatabase extends UiApplication
{
    public static void main(String[] args)
    {
        DeleteDatabase theApp = new DeleteDatabase();
        theApp.enterEventDispatcher();
    }
    
    public DeleteDatabase()
    {
        pushScreen(new DeleteDatabaseScreen());
    }   
}

class DeleteDatabaseScreen extends MainScreen
{
    Database d;
    public DeleteDatabaseScreen()
    {
        LabelField title = new LabelField("SQLite Delete Database Sample",
                                           LabelField.ELLIPSIS | 
                                           LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Deleting a database called " +
                              "MyTestDatabase.db on the SDCard."));
        try
        {
            URI myURI = URI.create("file:///SDCard/Databases/SQLite_Guide/" +
                                   "MyTestDatabase.db"); 
            DatabaseFactory.delete(myURI);       
        }
        catch ( Exception e ) 
        {         
            System.out.println( e.getMessage() );
            e.printStackTrace();
        }
    }
}

Was this information helpful? Send us your comments.