2015-10-20 298 views
4

我已决定为我的项目使用Realm。我浏览了文档,无法理解如何将所有手机联系人导入我的Realm数据库。 以前有没有人做过这样的项目?请帮忙。在Realm中批量插入

我已经使用了Sugar ORM,它有一个批量插入选项。 Realm是否有相同的或者是否有替代方案?

这是我做了什么至今:

package com.advisualinc.switchchat.Realm_DB; 

import io.realm.RealmObject; 
import io.realm.annotations.PrimaryKey; 

/** 
* Created by Veeresh on 10/19/2015. 
*/ 
public class R_ContactDB extends RealmObject { 
    private String name; 
    @PrimaryKey 
    private String phone; 
    private boolean matchedWithRecent; 
    private int status; 


    public R_ContactDB(String name, String phone, boolean matchedWithRecent, int status) 
    { 
     this.name = name; 
     this.phone = phone; 
     this.matchedWithRecent = matchedWithRecent; 
     this.status = status; 
    } 

    public R_ContactDB() 
    { 

    } 

    public String getName() { 
     return name; 
    } 

    public void setName(String name) { 
     this.name = name; 
    } 

    public String getPhone() { 
     return phone; 
    } 

    public void setPhone(String phone) { 
     this.phone = phone; 
    } 

    public boolean isMatchedWithRecent() { 
     return matchedWithRecent; 
    } 

    public void setMatchedWithRecent(boolean matchedWithRecent) { 
     this.matchedWithRecent = matchedWithRecent; 
    } 

    public int getStatus() { 
     return status; 
    } 

    public void setStatus(int status) { 
     this.status = status; 
    } 
} 
+0

为什么downvote?请帮助 –

+0

请更具体地说明您尝试过什么,哪些不起作用。 – Adrenaxus

+0

我有同样的查询 –

回答