title: is there any better way to import database from .realm file to device?
body: <p>I have a pre-initialized realm. I am going to copy into where it should be on device using snip of code below.</p>
  
  
  
  <pre><code>  //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)) &gt; 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)) &gt; 0) {
              out.write(buf, 0, len);
          }
          in.close();
          out.close();
      } 
  </code></pre>
  
  <p>So it will overwrite old realm file them write new realm file in same place.
  Is it right ways to import database.
  If not, how can I make it better ?</p>