Java Code Examples for mil.nga.geopackage.tiles.user.TileDao#queryForIdRow()
The following examples show how to use
mil.nga.geopackage.tiles.user.TileDao#queryForIdRow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileUtils.java From geopackage-java with MIT License | 5 votes |
/** * Test delete * * @param geoPackage * GeoPackage * @throws SQLException * upon error */ public static void testDelete(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); TestCase.assertNotNull(dao); TileResultSet cursor = dao.queryForAll(); int count = cursor.getCount(); if (count > 0) { // Choose random tile int random = (int) (Math.random() * count); cursor.moveToPosition(random); TileRow tileRow = cursor.getRow(); cursor.close(); // Delete row TestCase.assertEquals(1, dao.delete(tileRow)); // Verify deleted TileRow queryTileRow = dao.queryForIdRow(tileRow.getId()); TestCase.assertNull(queryTileRow); cursor = dao.queryForAll(); TestCase.assertEquals(count - 1, cursor.getCount()); cursor.close(); } cursor.close(); } } }
Example 2
Source File: TileUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test delete * * @param geoPackage GeoPackage * @throws SQLException upon error */ public static void testDelete(GeoPackage geoPackage) throws SQLException { TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { List<TileMatrixSet> results = tileMatrixSetDao.queryForAll(); for (TileMatrixSet tileMatrixSet : results) { TileDao dao = geoPackage.getTileDao(tileMatrixSet); TestCase.assertNotNull(dao); TileCursor cursor = dao.queryForAll(); int count = cursor.getCount(); if (count > 0) { // Choose random tile int random = (int) (Math.random() * count); cursor.moveToPosition(random); TileRow tileRow = cursor.getRow(); cursor.close(); // Delete row try { TestCase.assertEquals(1, dao.delete(tileRow)); } catch (SQLiteException e) { if (TestUtils.isFutureSQLiteException(e)) { continue; } else { throw e; } } // Verify deleted TileRow queryTileRow = dao.queryForIdRow(tileRow.getId()); TestCase.assertNull(queryTileRow); cursor = dao.queryForAll(); TestCase.assertEquals(count - 1, cursor.getCount()); cursor.close(); } cursor.close(); } } }