Exemple de code : mise à jour de données de table

/*
 * UpdateData.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 UpdateData extends UiApplication
{
    public static void main(String[] args)
    {
        UpdateData theApp = new UpdateData();
        theApp.enterEventDispatcher();
    }
    public UpdateData()
    {
        pushScreen(new UpdateDataScreen());
    }   
}
class UpdateDataScreen extends MainScreen
{
    Database d;
    public UpdateDataScreen()
    {
       LabelField title = new LabelField("SQLite Update Data Sample",
                                          LabelField.ELLIPSIS | 
                                          LabelField.USE_ALL_WIDTH);
       setTitle(title);
       add(new RichTextField("Trying to update data in MyTestDatabase.db."));
       try
       {
        URI myURI = URI.create("file:///SDCard/Databases/SQLite_Guide/" +
                               "MyTestDatabase.db"); 
        d = DatabaseFactory.open(myURI);
        Statement st = d.createStatement("UPDATE People SET Age=38 " +
                                         "WHERE Name='John'");
        st.prepare();
        st.execute();
        st.close();
        d.close();
        }
        catch ( Exception e ) 
        {         
            System.out.println( e.getMessage() );
            e.printStackTrace();
        }
    }
}

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