2012-09-03 46 views
0

我得到了iOS數據模型,包括16個實體(表我猜)。所以,當我正在做Android應用程序的版本時,我需要或自動導入此模型(首選方式),或者我需要創建SQL查詢才能完成此操作。現在使用iOS數據模型,並將其導入到Android的SQLite

,這是16桌,後來需要與網絡服務進行復制,所以我想保持數據庫精確原樣。

什麼是最好的方法解決這個問題,並在那裏把數據庫的建立,在原始數據庫被應用程序負載使用的一些偏好在那個特定的數據庫「設置」表中。

TNX

編輯1:XML從iOS的前兩個表型號:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<model name="" userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1487" systemVersion="11E53" minimumToolsVersion="Xcode 4.1" macOSVersion="Automatic" iOSVersion="Automatic"> 
<entity name="FAQItem" representedClassName="FAQItem" syncable="YES"> 
<attribute name="answer" attributeType="String" syncable="YES"/> 
<attribute name="orderNum" attributeType="Integer 16" defaultValueString="0" syncable="YES"/> 
<attribute name="question" attributeType="String" syncable="YES"/> 
</entity> 
<entity name="Ingredient" representedClassName="Ingredient" syncable="YES"> 
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/> 
<relationship name="recipe" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="Recipe" inverseName="ingredients" inverseEntity="Recipe" syncable="YES"/> 
</entity> 
+0

沒有我知道的自動方法。使用[ormlite](http://ormlite.com/sqlite_java_android_orm.shtml)可能最接近IOS數據模型 – zapl

+0

iOS datamodel是一個sqlite數據庫,您應該能夠在您的模擬器(或設備)的某處找到它)工作文件夾爲您的應用程序。 – mihail

+0

mihail,我從iOS開發者那裏得到了.xml。我沒有iOS模擬器,也不知道如何使用iOS和Xcode做任何事情:)所以,我有.xml的領域,我看到的實體,並應該將其導入到Android的SQLite。 TNX! – Balkyto

回答

0

做到這一點的唯一方法是寫誰解析XML DATAS的腳本,並生成Java類文件。它不是不可能的,但有點複雜。但我認爲這可能是一個非常好的主意!

相關問題