Import Data to Realm Database

给你一囗甜甜゛ 提交于 2019-12-04 19:35:08

As for now Realm does not seem to have the import functionality that you need. Check this thread for more information.

Realm does have a great documentation that you can read at Realm and for SQLite there is this framework (there are for sure more out there) and they both support Swift 2.x. You have to check what suits your requests most.

I can also recommend you to read this database thread at reddit.

public String composeJsonFromRealm(){
        ArrayList<HashMap<String, String>> wordList;
        wordList = new ArrayList<HashMap<String, String>>();
       // Build the query looking at all users:
        // Execute the query:
        RealmResults<User> users = realm.where(User.class).findAll();

        if (users.size()>0){
                User user = users.first();
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("name", user.getName());
                map.put("email",user.getEmail());
                wordList.add(map);


        }

        Gson gson = new GsonBuilder().create();

        return gson.toJson(wordList);

    }
ast

I am trying to import data from JSON and CSV into a Realm database. Does Realm have this functionality?

With Realm Cocoa Converter you can import CSV, XLSX, and JSON, and export CSV data. Though, at the moment, it only supports OS X.

As of now, Realm Studio does have the import functionality from CSV.

Open the Realm Studio, File -> Create Realm from -> CSV

Cheers,

Murat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!