Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 14th, 2012  |  syntax: None  |  size: 1.23 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Convert Android Code to MonoAndroid Code
  2. //Open your local db as the input stream
  3.     InputStream myInput = myContext.getAssets().open(DB_NAME);
  4.  
  5.     // Path to the just created empty db
  6.     String outFileName = DB_PATH + DB_NAME;
  7.  
  8.     //Open the empty db as the output stream
  9.     OutputStream myOutput = new FileOutputStream(outFileName);
  10.  
  11.     //transfer bytes from the inputfile to the outputfile
  12.     byte[] buffer = new byte[1024];
  13.     int length;
  14.     while ((length = myInput.read(buffer))>0){
  15.         myOutput.write(buffer, 0, length);
  16.     }
  17.  
  18.     //Close the streams
  19.     myOutput.flush();
  20.     myOutput.close();
  21.     myInput.close();
  22.        
  23. //Open your local db as the input stream
  24.     Stream myInput = Assets.Open(@"test.db");
  25.     string outFileName = Path.Combine(System.Environment.GetFolderPath  (System.Environment.SpecialFolder.Personal), "test.db");
  26.         //Open the empty db as the output stream
  27.       Stream myOutput = new FileStream(outFileName,FileMode.OpenOrCreate);
  28.     byte[] buffer = new byte[1024];
  29.     int b = buffer.Length;
  30.     int length;
  31.     while ((length = myInput.Read(buffer,0,b))>0){
  32.         myOutput.Write(buffer, 0, length);
  33.      }
  34.     //Close the streams
  35.     myOutput.Flush();
  36.     myOutput.Close();
  37.     myInput.Close();
  38.  }