Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 27
Registered: ‎02-20-2013
My Device: 9900
My Carrier: Telkomsel
Accepted Solution

Inserting data into database java blackberry

here is my code to insert data into database

package mypackage;

import net.rim.device.api.database.Database;
import net.rim.device.api.database.DatabaseFactory;
import net.rim.device.api.database.Statement;
import net.rim.device.api.io.URI;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

//class untuk insert data ke database table People

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:///Store/Databases/SQLite_Guide/" +
                                   "MyTestDatabase2.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();
            add(new RichTextField("inserting data successful"));
            System.out.println( "inserting data successful" );
        }
        catch ( Exception e ) 
        {         
            System.out.println( e.getMessage() );
            e.printStackTrace();
        }
        
             
    }
}

i have checked that database is exist. when i run code above, my data was never inserted into database, code bellow

add(new RichTextField("inserting data successful"));

never called.

 

anyone know what is my wrong? please

Highlighted
Contributor
Posts: 27
Registered: ‎02-20-2013
My Device: 9900
My Carrier: Telkomsel

Re: Inserting data into database java blackberry

help me please, anyone.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Inserting data into database java blackberry

When you step through this code in the debugger what happens?

Contributor
Posts: 27
Registered: ‎02-20-2013
My Device: 9900
My Carrier: Telkomsel

Re: Inserting data into database java blackberry

[ Edited ]

Problem solved!

 

i have successfully insert and view data on database when i change the storage location into SDCard

 

i dont know why, but its probably that blackberry can't save SQLite database on internal memory (OS7)