Windows 10上的Realm数据浏览器



我设法得到出口。使用这些代码的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, 0, 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, 0, len);
        }
        in.close();
        out.close();
    }
}

现在我想去看看。如何在windows中编辑它。开发者说他们只在Mac上有领域浏览器但我用的是windows 10。大家有什么方法或工具可以进入Windows的浏览器领域吗?谢谢你。

(免责声明:我是负责Mac领域浏览器的人:))

我们听到了!不幸的是,现在,甚至考虑一个Windows版本的Realm浏览器,我们需要让Realm本身在Windows上运行!这绝对是我们正在努力的事情,但显然这不是一个小工作量;所以我们还没有任何发布时间表。

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

很抱歉我不能带来任何更好的消息,但至少,我希望这在过渡期间有所帮助。但我们100%意识到,在Windows上拥有一个同等版本的Realm浏览器将极大地帮助Android在该平台上的开发。

另一个解决方案,有第三方的Stetho Realm插件https://github.com/uPhyca/stetho-realm, Stetho是Facebook开发的Android调试桥。它还可以让你在你的设备上看到Realm的数据。

我刚刚以Android Studio插件的形式编写了一个微不足道的Realm Browser (Rebro)。不确定需求有多大,这更像是一种挑战。不管怎样,现在开始:https://github.com/Ghedeon/Rebro

查看了所有的旧答案后,我想到把我的最新研究放在这个帖子上。

根据下面的链接,他们还没有为windows准备任何东西。如果你用的是mac,那就太幸运了。

https://realm.io/docs/java/latest/

但是他们提到了facebook用来浏览和编辑领域数据的实用程序。

http://facebook.github.io/stetho/

PS:那些不知道如何从chrome浏览器调试应用程序的人,你可以通过点击右上角的三个垂直点来检查设备选项。访问更多工具->>开发人员工具->>再次单击三个垂直点->>更多选项->>>检查设备。之后,您将看到与上面链接中的功能相同的UI。

最新更新