Windows 10上的Realm数据浏览器

前端之家收集整理的这篇文章主要介绍了Windows 10上的Realm数据浏览器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我设法使用这些代码获取export.realm
  1. package com.meow.meowmeow;
  2. import android.content.Context;
  3. import android.content.Intent;
  4. import android.content.res.AssetManager;
  5. import android.net.Uri;
  6. import android.util.Log;
  7.  
  8. import java.io.File;
  9. import java.io.FileInputStream;
  10. import java.io.FileOutputStream;
  11. import java.io.IOException;
  12. import java.io.InputStream;
  13. import java.io.OutputStream;
  14.  
  15. import io.realm.Realm;
  16. import io.realm.RealmConfiguration;
  17.  
  18. /**
  19. * Created by Thien on 9/1/2015.
  20. */
  21. public class RealmTool {
  22. private static String LOG_TAG = "RealmTool";
  23.  
  24. //export to email
  25. public static void exportDatabase(Context context,RealmConfiguration configuration) {
  26.  
  27. // init realm
  28. Realm realm = Realm.getInstance(configuration);
  29.  
  30. File exportRealmFile = null;
  31. try {
  32. // get or create an "export.realm" file
  33. exportRealmFile = new File(context.getExternalCacheDir(),"export.realm");
  34.  
  35. // if "export.realm" already exists,delete
  36. exportRealmFile.delete();
  37.  
  38. // copy current realm to "export.realm"
  39. realm.writeCopyTo(exportRealmFile);
  40.  
  41.  
  42. } catch (IOException e) {
  43. e.printStackTrace();
  44. }
  45. realm.close();
  46.  
  47. // init email intent and add export.realm as attachment
  48. Intent intent = new Intent(Intent.ACTION_SEND);
  49. intent.setType("plain/text");
  50. intent.putExtra(Intent.EXTRA_EMAIL,"YOUR MAIL");
  51. intent.putExtra(Intent.EXTRA_SUBJECT,"YOUR SUBJECT");
  52. intent.putExtra(Intent.EXTRA_TEXT,"YOUR TEXT");
  53. Uri u = Uri.fromFile(exportRealmFile);
  54. intent.putExtra(Intent.EXTRA_STREAM,u);
  55.  
  56. // start email intent
  57. context.startActivity(Intent.createChooser(intent,"YOUR CHOOSER TITLE"));
  58. }
  59.  
  60. //import from assets
  61. public static RealmConfiguration importDatabase(Context context,String realm_file_name){
  62. RealmConfiguration defaultRealm = new RealmConfiguration.Builder(context).build();
  63. String dir = defaultRealm.getPath();
  64. AssetManager assetManager = context.getAssets();
  65. try {
  66. InputStream is;
  67. is = assetManager.open(realm_file_name);
  68. File dest = new File(dir);
  69. if (dest.exists())
  70. dest.delete();
  71. copy(is,dest);
  72. }catch (IOException e){
  73. Log.e(LOG_TAG,"import database error");
  74. }
  75. return defaultRealm;
  76. }
  77.  
  78. public static void copy(File src,File dst) throws IOException {
  79. InputStream in = new FileInputStream(src);
  80. OutputStream out = new FileOutputStream(dst);
  81.  
  82. // Transfer bytes from in to out
  83. byte[] buf = new byte[1024];
  84. int len;
  85. while ((len = in.read(buf)) > 0) {
  86. out.write(buf,len);
  87. }
  88. in.close();
  89. out.close();
  90. }
  91. public static void copy(InputStream in,File dst) throws IOException {
  92.  
  93. OutputStream out = new FileOutputStream(dst);
  94.  
  95. // Transfer bytes from in to out
  96. byte[] buf = new byte[1024];
  97. int len;
  98. while ((len = in.read(buf)) > 0) {
  99. out.write(buf,len);
  100. }
  101. in.close();
  102. out.close();
  103. }
  104.  
  105. }

现在我想检查一下
如何在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相关文章