title: copy a database file programatically from asset folder of the application
body: <p>I have searched a lot about this problem.My phone is not rooted. I want to copy a database file programmatically from my asset folder of the application to  /system/usr of my Android device. So that i can access the database file from there and check whether my app's users were being able to upgrade the database. I know that i have to change the 'outFileName' and "outputStream" in the following  code but i am not exactly sure how to specify the output path for /sytem/usr in the following code:</p>
  
  <pre><code>copyDBfromassetstodevicedrive.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  try {
                      // Open your local db as the input stream
                      InputStream myInput = myContext.getAssets().open("myDB.db");
  
                      // Path to the just created empty db
                      String outFileName = "/data/data/your app package name/databases/database file name";
  
                      OutputStream myOutput = new FileOutputStream(outFileName);
  
                      // transfer bytes from the inputfile to the outputfile
                      byte[] buffer = new byte[1024];
                      int length;
                      while ((length = myInput.read(buffer)) &gt; 0) 
                       {
                           myOutput.write(buffer, 0, length);
                       }
  
                      // Close the streams
                      myOutput.flush();
                      myOutput.close();
                      myInput.close();
                      } 
                      catch (Exception e) 
                      {
                      Log.e("error", e.toString());
                      }
  
              }
            });
  </code></pre>
  
  <p>thanks for any suggestions. </p>