Mass insertion into the kingdom

I decided to use Realm for my project. I looked through the documentation and cannot figure out how to get all my phone contacts imported into my Realm database. Has anyone done this project before? Please, help.

I used Sugar ORM, which has a bulk insert option. Does the Kingdom have the same thing, or is there an alternative to this?

Here is what I have done so far:

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;
    }
}
+4
source share
2 answers

With Realm, there is no need for anything that directly matches the bulk inserts available in SQLite. There is no overhead in the query language.

Realm # copyToRealm, . JSON, Realm # createOrUpdateAllFromJson (JSONArray).

+3

2016 api

realm.insertOrUpdate(Collections datas);

, , . https://realm.io/blog/realm-java-1-1-0/

0

Source: https://habr.com/ru/post/1612353/


All Articles