public boolean createRelatedTable ( UserTable < ? extends UserColumn > relatedTable ) { boolean created = false ; String relatedTableName = relatedTable . getTableName ( ) ; if ( ! geoPackage . isTable ( relatedTableName ) ) { geoPackage . createUserTable ( relatedTable ) ; try { // Create the contents Contents contents = new Contents ( ) ; contents . setTableName ( relatedTableName ) ; contents . setDataTypeString ( relatedTable . getDataType ( ) ) ; contents . setIdentifier ( relatedTableName ) ; ContentsDao contentsDao = geoPackage . getContentsDao ( ) ; contentsDao . create ( contents ) ; contentsDao . refresh ( contents ) ; relatedTable . setContents ( contents ) ; } catch ( RuntimeException e ) { geoPackage . deleteTableQuietly ( relatedTableName ) ; throw e ; } catch ( SQLException e ) { geoPackage . deleteTableQuietly ( relatedTableName ) ; throw new GeoPackageException ( "Failed to create table and metadata: " + relatedTableName , e ) ; } created = true ; } return created ; }
Create a user related table if it does not exist . When not created there is no guarantee that an existing table has the same schema as the provided tabled .