Esempio di codice: inserimento di dati nella tabella

/*
 * InsertData.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 InsertData extends UiApplication
{
    public static void main(String[] args)
    {
        InsertData theApp = new InsertData();
        theApp.enterEventDispatcher();
    }
    public InsertData()
    {
        pushScreen(new InsertDataScreen());
    }   
}
class InsertDataScreen extends MainScreen
{
    Database d;
    public InsertDataScreen()
    {
        LabelField title = new LabelField("SQLite Insert Data " +
                                          "Schema Sample", 
                                          LabelField.ELLIPSIS | 
                                          LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Attempting to insert data into " +
                               "MyTestDatabase.db on the SDCard."));
        try
        {
            URI myURI = URI.create("file:///SDCard/Databases/SQLite_Guide/" +
                                   "MyTestDatabase.db"); 
            d = DatabaseFactory.open(myURI);
            Statement st = d.createStatement("INSERT INTO People(Name,Age) " +
                                             "VALUES ('John',37)");
            st.prepare();
            st.execute();
            st.close();
            d.close();
        }
        catch ( Exception e ) 
        {         
            System.out.println( e.getMessage() );
            e.printStackTrace();
        }
    }
}

Le informazioni sono state utili? Inviateci i vostri commenti.