Closed sunshine0576 closed 5 years ago
You are welcome to utilize the connection directly as follows.
boolean successful = Math.random() < 0.5 ? true : false;
int countBefore = featureDao.count();
int rows = 10;
SQLiteDatabase db = featureDao.getDatabaseConnection().getDb();
db.beginTransaction();
try{
for(int i = 0; i < rows; i++) {
FeatureRow row = featureDao.newRow();
GeoPackageGeometryData geometry = new GeoPackageGeometryData(
geometryColumns.getSrsId());
geometry.setGeometry(new Point(0, 0));
row.setGeometry(geometry);
featureDao.insert(row);
}
if(successful) {
db.setTransactionSuccessful();
}
}catch(Exception e){
}finally{
db.endTransaction();
}
int countAfter = featureDao.count();
TestCase.assertEquals(successful ? countBefore + rows : countBefore, countAfter);
The other connection is for common GeoPackage core and ORM Lite operations.
The SQLite database supports transactional operations, but the current version of Geopackage is too cumbersome to use.
SQLiteDatabase db=featureDao.getDb().getDb().getDb();
SQLiteDatabase db1= featureDao.getDatabaseConnection().getDb();