You are here: Platform Specific Issues > Android > Comparison With SQLite > Storing Data

Storing Data

Storing a car-object in is very-different in SQLite and db4o.

SQLite

ContentValues initialValues = new ContentValues();

initialValues.put("id", number);
initialValues.put("name", "Tester");
initialValues.put("points", number);
db.insert(DB_TABLE_PILOT, null, initialValues);

initialValues = new ContentValues();

initialValues.put("model", "BMW");
initialValues.put("pilot", number);
db.insert(DB_TABLE_CAR, null, initialValues);
SqlExample.java: store a car in SQLite

db4o

Car car = new Car("BMW");
car.setPilot(new Pilot("Tester", points));
container.store(car);
Db4oExample.java: store a car in db4o

Conclusion

You can see that db4o handles adding objects to the database in a much more elegant way - #store(object) method is enough. In SQLite case it is much more difficult as you mush store different objects into different tables. Some of the additional work that SQLite developer will have to do is not visible in this example, i.e: