My problem is whenever I first create a database in SDCard and also making a table and inserting some values inside it is working fine . But only once, if now i want to add some more data in my existed DB What i am doing is , I am going to the class where I have written the insert statement and inserting some more values but when i run my application and browsing my database in SQLite database browser it doesnot deflect any changes. I cant see my new inserted values
import net.rim.device.api.ui.UiApplication;
public class InsertDataScreen extends UiApplication {
public static void main(String[] args) {
InsertDataScreen theApp = new InsertDataScreen();
theApp.enterEventDispatcher();
}
public InsertDataScreen() {
pushScreen(new CreateDatabaseScreen());
}
}
and my second class is this where i was creating the database and inserting value when i have done this my database created with one row now i want to add one more row inside my database for that I have commented the Insert Statement when i done that i was expecting two rows inside but it doesnot changed...
import net.rim.device.api.database.Database;
import net.rim.device.api.database.DatabaseFactory;
import net.rim.device.api.database.Row;
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;
public class CreateDatabaseScreen extends MainScreen {
Database d;
public CreateDatabaseScreen(){
LabelField title = new LabelField("SQLite Create database sample and " +
"inserting some value ",
LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new RichTextField("Creating a Database and will Add some data" +
"MyTest.db on the SDCard"));
try {
URI uri = URI.create("file:///SDCard/Databases/SQLite_Guide/" +
"MyTestDatabase.db");
d = DatabaseFactory.create(uri);
d.close();
d = DatabaseFactory.open(uri);
Statement s = d.createStatement( "CREATE TABLE 'People' ( " +
"'Name' TEXT, " +
"'Age' INTEGER )");
s.prepare();
s.execute();
s.close();
Statement s1 = d.createStatement("INSERT INTO People(Name,Age) " +
"VALUES ('Uttam',23)");
s1.prepare();
s1.execute();
s1.close();
/**
Statement s2 = d.createStatement("INSERT INTO People(Name,Age) " +
"VALUES ('Rakesh',26)");
s2.prepare();
s2.execute();
s2.close();
*/
d.close();
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}