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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
Scientific
Posts: 90
Registered: ‎06-04-2010
My Carrier: verizon
Accepted Solution

Problem Sql-Lite

I've looked at the documentation and lots of examples, but I can't seem to get my sql-lite database going.

 

I created the database in the mainscreen here:

 

URI myURI = URI.create("file:///SDCard/flash.sqlite");
				
d = DatabaseFactory.create(myURI);
				 
d.close();

 

 

I tried to save info into the database here:

URI myURI = URI.create("file:///SDCard/flash.sqlite");
 DatabaseFactory.open(myURI);
    				    
 Statement st = d.createStatement( "CREATE TABLE 'Restaurant' (  'Experience' TEXT,  )" );
    					
 d.createStatement("INSERT INTO Restaurant(Experience) " +
 "VALUES ('message1')");
    					
 st.prepare();
 st.execute();
 st.close();
 d.close();
    					
 Dialog.alert("Your info was saved!");   	

 

Any ideas what im doing wrong?

 

Thanks

 

Scientific

Please use plain text.
Contributor
ddgeek
Posts: 26
Registered: ‎11-30-2010

Re: Problem Sql-Lite

Hey

try this

 

URI myURI = URI.create("file:///SDCard/flash.db");

d = DatabaseFactory.create(myURI);

d.close();

 

URI myURI = URI.create("file:///SDCard/flash.sqlite");
DatabaseFactory.open(myURI);

Statement st = d.createStatement( "CREATE TABLE 'Restaurant' ( 'Experience' TEXT)" );

st.prepare();
st.execute();
st.close();

Statement st1 = d.createStatement("INSERT INTO Restaurant(Experience) " +
"VALUES ('message1')");

st1.prepare();
st1.execute();
st1.close();
d.close();

Dialog.alert("Your info was saved!");
Please use plain text.
Developer
nitinverma274
Posts: 950
Registered: ‎06-22-2010

Re: Problem Sql-Lite

Separate Statement Object for the Insert statement.

 

Statement st1 = d.createStatement("INSERT INTO Restaurant(Experience) " +
"VALUES ('message1')");

And Now

 

st.prepare();
st.execute();
st1.prepare();
st1.execute();

------------------------------------------------------------------------------------

Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution.

 

 

 

 

 

 

 

 

Please use plain text.
Contributor
ddgeek
Posts: 26
Registered: ‎11-30-2010

Re: Problem Sql-Lite

Dont write flash.sqllite.....

 

just write 

 

 

file:///SDCard/flash.db"
Please use plain text.
Developer
Scientific
Posts: 90
Registered: ‎06-04-2010
My Carrier: verizon

Re: Problem Sql-Lite

Hello, I have tried the example you gave me and still nothing work?

 

Any other ideas?

 

Scientific

Please use plain text.
Contributor
ddgeek
Posts: 26
Registered: ‎11-30-2010

Re: Problem Sql-Lite

It should work

 

bcz i m working on dat only.

 

You must be doing sumthing wrong.

 

Just check your code.

 

Debug your code you wl find out error.

 

Try like dat.

 

 

 

URI myURI = URI.create("file:///SDCard/database/flash.db");
Please use plain text.