I have a pre packages SQL database. Which has cou...
# android
p
I have a pre packages SQL database. Which has couple of Boolean fields. When I import that DB using Room it's throwing an error staying Pre packaged database has invalid schema I'm guessing problem is that, DB has boolen field type but Room table we can't have Boolean its being used and Integer field. How can I solve this??
i
The only option is to fix your database to use the same schema that Room expects. You can copy the create table statement out of the schema file that Room generated
p
@Ian Lake thank you for your time. This DB file I'm downloading from remote location which has Boolen fields in it. Unfortunately, I can control the schema of the DB that I receive. You mean to say, there is no fix for the issue I'm facing.
Copy code
Caused by: java.lang.IllegalStateException: Pre-packaged database has an invalid schema: facility(org.kp.m.dashboard.home.data.geofencing.model.Facility).
09-14 18:40:03.805  979  979 E AndroidRuntime: Expected:
09-14 18:40:03.805  979  979 E AndroidRuntime: TableInfo{name='facility', columns={zip=Column{name='zip', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, afterHoursInd=Column{name='afterHoursInd', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, isPreferedFacility=Column{name='isPreferedFacility', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasEmergencyServices=Column{name='hasEmergencyServices', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, city=Column{name='city', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, timezone=Column{name='timezone', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, latitude=Column{name='latitude', type='REAL', affinity='4', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasByAppointment=Column{name='hasByAppointment', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, cpmFacilityId=Column{name='cpmFacilityId', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hospitalInd=Column{name='hospitalInd', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, facilityDescription=Column{name='facilityDescription', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, street=Column{name='street', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, name=Column{name='name', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, ncalInd=Column{name='ncalInd', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, affiliateInd=Column{name='affiliateInd', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, isHospital=Column{name='isHospital', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasWalkInCare=Column{name='hasWalkInCare', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, _id=Column{name='_id', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=1, defaultValue='null'}, state=Column{name='state', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, region=Column{name='region', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasAfterHoursCare=Column{name='hasAfterHoursCare', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, spotlightKey=Column{name='spotlightKey', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, formattedHours=Column{name='formattedHours', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, longitude=Column{name='longitude', type='REAL', affinity='4', notNull=false, primaryKeyPosition=0, defaultValue='null'}}, foreignKeys=[], indices=[]}
09-14 18:40:03.805  979  979 E AndroidRuntime: Found:
09-14 18:40:03.806  979  979 E AndroidRuntime: TableInfo{name='facility', columns={afterHoursInd=Column{name='afterHoursInd', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, isPreferedFacility=Column{name='isPreferedFacility', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, city=Column{name='city', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, timezone=Column{name='timezone', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, latitude=Column{name='latitude', type='REAL', affinity='4', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasByAppointment=Column{name='hasByAppointment', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, cpmFacilityId=Column{name='cpmFacilityId', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, street=Column{name='street', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, affiliateInd=Column{name='affiliateInd', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, isHospital=Column{name='isHospital', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasWalkInCare=Column{name='hasWalkInCare', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, state=Column{name='state', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasAfterHoursCare=Column{name='hasAfterHoursCare', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, formattedHours=Column{name='formattedHours', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, longitude=Column{name='longitude', type='REAL', affinity='4', notNull=false, primaryKeyPosition=0, defaultValue='null'}, zip=Column{name='zip', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasUrgentCare=Column{name='hasUrgentCare', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hasEmergencyServices=Column{name='hasEmergencyServices', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, hospitalInd=Column{name='hospitalInd', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, facilityDescription=Column{name='facilityDescription', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, name=Column{name='name', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, ncalInd=Column{name='ncalInd', type='BOOLEAN', affinity='1', notNull=false, primaryKeyPosition=0, defaultValue='null'}, _id=Column{name='_id', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=1, defaultValue='null'}, region=Column{name='region', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, spotlightKey=Column{name='spotlightKey', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}}, foreignKeys=[], indices=[]}
This is the exception I'm getting 🙄🙄
i
Your schema needs to match exactly
🙄 1
c
@pollux- the data seems simple enough. Can you just download it and insert it into the database instead? If you don't control it, I don't think there is much you can do like Ian said.
p
@Colton Idle 🙏
Thanks guys ✌️ @Colton Idle @Ian Lake
@Colton Idle @Ian Lake I had changed the type matching the SQL lite type and problem solved .. Thanks a lot
👍 2