2016-01-27 28 views
1

我正在創建一個使用糖ORM表,但recof錯誤沒有這樣的表。即使在Android Manifest中將版本更新爲更高值之後。否這樣的表存在異常,糖ORM Android

public class CachedVidcodes extends SugarRecord { 
    private String vidcodeId; 
    private String vidcodedownloadedPath; 
    public CachedVidcodes(){ 
    } 

    public CachedVidcodes(String vidcodeId, String vidcodedownloadedPath){ 
     this.vidcodeId = vidcodeId; 
     this.vidcodedownloadedPath = vidcodedownloadedPath; 
    } 
    public String getVidcodeId() { 
     return vidcodeId; 
    } 

    public void setVidcodeId(String vidcodeId) { 
     this.vidcodeId = vidcodeId; 
    } 

    public String getVidcodedownloadedPath() { 
     return vidcodedownloadedPath; 
    } 

    public void setVidcodedownloadedPath(String vidcodedownloadedPath) { 
     this.vidcodedownloadedPath = vidcodedownloadedPath; 
    } 

} 

Android清單詳情如下

<meta-data 
      android:name="DATABASE" 
      android:value="vd.db" /> 
     <meta-data 
      android:name="VERSION" 
      android:value="2" /> 
     <meta-data 
      android:name="QUERY_LOG" 
      android:value="true" /> 
     <meta-data 
      android:name="DOMAIN_PACKAGE_NAME" 
      android:value="com.vf.vde.ormclasses" /> 
+0

卸載並重新安裝您的應用程序 –

+0

@ HrundiV.Bakshi,也沒有工作 –

回答

1
This problem can be solved by creating an empty "migration script file with new version". 
This can be simply done by following : 
1. Create your new Sugar record class. 
2. In Android manifest file just increase the DB version. 
3. Add an empty migration script file named after the new DB version, placed under assets/sugar_upgrades. (example. 2.sql). 
By doing this, it creates the new table without dropping/creating my old tables. 
0

我解決我的問題,以增加從事AndroidManifest的DB_VERSION的號碼,以便您可以:

<meta-data android:name="VERSION" android:value="2" /> 

和forexample更改到3:

<meta-data android:name="VERSION" android:value="3" />