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

Reply
Contributor
Posts: 49
Registered: ‎12-21-2010
My Device: 9000 Bold Device
My Carrier: software developer

Re: Sqlite issue

hi,

 

 Actually I want to insert the data into a database table using BasicEditFeild in sql lite.

i dont i have any idea to do that.any one having any sample code or example.please help me

 

Thanks

Contributor
Posts: 49
Registered: ‎12-21-2010
My Device: 9000 Bold Device
My Carrier: software developer

Re: Sqlite issue

hi,

 

Nobody knows how to  insert the data into a database table using BasicEditFeild in sql lite.

if anybody knows please give me sample code.

 

Thanks

Trusted Contributor
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: Sqlite issue

for db on devices less than 9800 you must put the db file on the sdcard.

 

i faced the same problem.

Developer
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: Sqlite issue

nothing special in that case also, just extract data from basicEditField using getText and then pass as parameter in query.....................


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Contributor
Posts: 49
Registered: ‎12-21-2010
My Device: 9000 Bold Device
My Carrier: software developer

Re: Sqlite issue

hi,

 

I have added basic edit fields and am alos added to buttons, if i click on ok button then the data has to store in data base, it is not working, here is my code.

 

public class CInsertIntoTable extends MainScreen{
    public static BasicEditField  m_name, m_age;
    ButtonField     m_OkButton, m_CancelButton;
    VerticalFieldManager  m_verticalManager;
    HorizontalFieldManager m_horizontalManager;
    Database sqliteDB;
    public CInsertIntoTable() {
        m_verticalManager = new VerticalFieldManager(NO_VERTICAL_SCROLL | USE_ALL_HEIGHT);
        
        m_horizontalManager = new HorizontalFieldManager();
        
        m_name = new BasicEditField("Name: ", "", 50, BasicEditField.NO_COMPLEX_INPUT | BasicEditField.FIELD_HCENTER);
        m_age = new BasicEditField("Age: ", "", 3, BasicEditField.NO_COMPLEX_INPUT | BasicEditField.FIELD_HCENTER | BasicEditField.FILTER_INTEGER);
        
        m_OkButton = new ButtonField("Ok");
        m_CancelButton = new ButtonField("Cancel");
        
        m_verticalManager.add(m_name);
        m_verticalManager.add(m_age);
        m_horizontalManager.add(m_OkButton);
        m_horizontalManager.add(m_CancelButton);
        m_verticalManager.add(m_horizontalManager);
        add(m_verticalManager);
    }
    protected boolean navigationClick(int status, int time)
    {
        if(m_OkButton.isFocus()){
            Statement stmt;
            try {
                URI myURI = URI.create("file:///store/Databases/blackberry.db");
                   sqliteDB = DatabaseFactory.open(myURI);
                stmt = sqliteDB.createStatement("INSERT INTO Employee(Name,Age) " +
                        "VALUES (" + "'" + m_name.getText() + "'," + "'" + m_age.getText() +"')");
                stmt.execute();
                stmt.close();

               sqliteDB.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else{
            if(m_CancelButton.isFocus()){
                Dialog.alert("The data is"+" "+m_name.getText()+m_age.getText());
                //UiApplication.getUiApplication().popScreen(this);
            }
        }
        return true;
    }

please help me where am doing mistake.

Thanks

Developer
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: Sqlite issue

is there any exception???


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Contributor
Posts: 49
Registered: ‎12-21-2010
My Device: 9000 Bold Device
My Carrier: software developer

Re: Sqlite issue

hi,

Thanks for responce.........

No Exception, but if i click on ok button nothing is happening. i am not getting what is the problem.

 

Thanks

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

Re: Sqlite issue

I would be reasonably confident that you have not "wired up" your controls properly.  In other words  a click on your OK button is not actually causing your navigationClick processing to get control.  Have you put a break point in there to confirm you are going through your code?  If not, then you should look for another way of firing your event, such as using a FieldChangeListener. 

Developer
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: Sqlite issue

may be u are using a different way, but i would prefer the following as i use it myself::

better u override navigationClick on button to notify change

implement FIeld change listener

set button to listen change using ur implementaion

 

 

 

 

////inside overridden button
protected boolean navigationClick(int status, int time) {
		this.fieldChangeNotify(2);
		return true;
	}


///something in field change listener
public void fieldChanged(Field field, int context) {
		if (field instanceof EditField) {

		}

///put somewhere u initializes the button 
button.setChangeListener(OBJECT_of_ur_Listener_Implementation); 

 

 

 


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Contributor
Posts: 49
Registered: ‎12-21-2010
My Device: 9000 Bold Device
My Carrier: software developer

Re: Sqlite issue

hi,

 

I am overriding  touch event method, am getting exception INSERT INTO Employee(Name, Age) VALUES

('tanu', '5') : sql logic error or missing database.

am doing any mistake in query, please help me

 

Thanks