Accessing iOS Core Data from Android
I developed a simple iPhone app by the book, using Core Data. The data is immutable and stored in a preloaded sqlite database, managed by Core Data.
Now I need to develop the (almost) same 开发者_如何学运维app for Android. I'm about to write a very basic set of classes that mimic Core Data, and read from the exact same sqlite database.
Before getting started on this, I was wondering if anyone knows about an Android library that does just this.
In theory, you could almost literally provide the same API as iOS does, maybe even parsing the object model as well.
Core Data have its own data structure you can look at it and you will see something like this:
Tables from your model are prefixed by Z, so you can perfectly query this SQLite Database with SQL queries in Android.
Note: you can find this SQLite file after runnig your app with Simulator in the folder: /Users/<you_name>/Library/Application Support/iPhone Simulator/<ios_version>/Applications/<app_id>/Documents/<app_name>.sqlite
In a more complex project, we used greenDAO as an replacement for Core Data when migrating code from iOS to Android. It does not come with visual modelling, but the basic operations quite similar. Being an ORM tool, greenDAO maps Java objects to SQLite and offers stuff like relations, too.
精彩评论