12-08-2010 02:16 AM
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
Solved! Go to Solution.
12-08-2010 02:25 AM
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!");
12-08-2010 02:26 AM
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.
12-08-2010 02:26 AM
Dont write flash.sqllite.....
just write
file:///SDCard/flash.db"
12-08-2010 02:38 AM
Hello, I have tried the example you gave me and still nothing work?
Any other ideas?
Scientific
12-08-2010 03:28 AM
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");