Exemple de code : suppression d'une base de données SQLite

/*
 * DeleteDatabase.java
 *
 * Research In Motion Limited proprietary and confidential
 * Copyright Research In Motion Limited, 2010
 */
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();
        }
    }
}

Ces informations vous ont-elles été utiles ? Envoyez-nous vos commentaires.