Windows 10上的Realm数据浏览器

前端之家收集整理的这篇文章主要介绍了Windows 10上的Realm数据浏览器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我设法使用这些代码获取export.realm
package com.meow.meowmeow;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.net.Uri;
import android.util.Log;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import io.realm.Realm;
import io.realm.RealmConfiguration;

/**
 * Created by Thien on 9/1/2015.
 */
public class RealmTool {
    private static String LOG_TAG = "RealmTool";

    //export to email
    public static void exportDatabase(Context context,RealmConfiguration configuration) {

        // init realm
        Realm realm = Realm.getInstance(configuration);

        File exportRealmFile = null;
        try {
            // get or create an "export.realm" file
            exportRealmFile = new File(context.getExternalCacheDir(),"export.realm");

            // if "export.realm" already exists,delete
            exportRealmFile.delete();

            // copy current realm to "export.realm"
            realm.writeCopyTo(exportRealmFile);


        } catch (IOException e) {
            e.printStackTrace();
        }
        realm.close();

        // init email intent and add export.realm as attachment
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("plain/text");
        intent.putExtra(Intent.EXTRA_EMAIL,"YOUR MAIL");
        intent.putExtra(Intent.EXTRA_SUBJECT,"YOUR SUBJECT");
        intent.putExtra(Intent.EXTRA_TEXT,"YOUR TEXT");
        Uri u = Uri.fromFile(exportRealmFile);
        intent.putExtra(Intent.EXTRA_STREAM,u);

        // start email intent
        context.startActivity(Intent.createChooser(intent,"YOUR CHOOSER TITLE"));
    }

    //import from assets
    public static RealmConfiguration importDatabase(Context context,String realm_file_name){
        RealmConfiguration defaultRealm = new RealmConfiguration.Builder(context).build();
        String dir = defaultRealm.getPath();
        AssetManager assetManager = context.getAssets();
        try {
            InputStream is;
            is = assetManager.open(realm_file_name);
            File dest = new File(dir);
            if (dest.exists())
                dest.delete();
            copy(is,dest);
        }catch (IOException e){
            Log.e(LOG_TAG,"import database error");
        }
        return defaultRealm;
    }

    public static void copy(File src,File dst) throws IOException {
        InputStream in = new FileInputStream(src);
        OutputStream out = new FileOutputStream(dst);

        // Transfer bytes from in to out
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf,len);
        }
        in.close();
        out.close();
    }
    public static void copy(InputStream in,File dst) throws IOException {

        OutputStream out = new FileOutputStream(dst);

        // Transfer bytes from in to out
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf,len);
        }
        in.close();
        out.close();
    }

}

现在我想检查一下
如何在Windows中编辑它.
开发者说他们在Mac上只有realm浏览器
但我正在使用Windows 10.
所以任何人都有任何方法或任何工具来浏览器在Windows领域.
谢谢.

(免责声明:我是Mac的Realm Browser负责人:))

我们听到你的声音不幸的是,现在甚至要考虑一个Windows版本的Realm Browser,我们需要让Windows本身运行在Windows上才能开始!这是我们绝对的工作,但显然这不是很少的工作;所以我们还没有任何发布时间表.

目前来说,如果您想从Android应用程式调试Realm文件,实际上是一个非常酷的开源第三方Android Realm浏览器应用程序,您可以使用它:https://github.com/dmytrodanylyk/realm-browser

对不起,我不能带来任何更好的消息,但至少我希望在此期间有所帮助.但是,我们100%的意识到在Windows上具有同等版本的Realm Browser将极大地帮助该平台上的Android开发.

猜你在找的Windows相关文章