title: Unable to read a Sqlite DB from Assets folder Android
body: <p>I can't read a Sqlite database from the Android Assets folder, if I do a debug it always throws an IOException, here is my code:</p>
  <p>Another question, should I use &quot;/data/data/com.example.bat0/databases/&quot; or &quot;/databases/&quot;? the database is located in the assets/databases folder</p>
  <pre><code>public class SqlLiteDbHelper extends SQLiteOpenHelper {
  
      private static final String DB_NAME = &quot;db_toulouse_barcelona.sqlite&quot;;
      private static final String DB_PATH =  &quot;/data/data/com.example.bat0/databases/&quot;;
      //private static final String DB_PATH =  &quot;/databases/&quot;;
      private Context context;
  
      public SqlLiteDbHelper(Context context) {
          super(context, DB_NAME, null, 1);
          this.context = context;
      }
  
      public SQLiteDatabase openDataBase() {
          File dbFile = context.getDatabasePath(DB_PATH+DB_NAME);
  
          if (!dbFile.exists()) {
              try {
                  android.database.sqlite.SQLiteDatabase checkDB = context.openOrCreateDatabase(DB_PATH+DB_NAME, context.MODE_PRIVATE, null);
                  if(checkDB != null){
  
                      checkDB.close();
  
                  }
                  copyDatabase(dbFile);
              } catch (IOException e) {
                  throw new RuntimeException(&quot;Error creating source database&quot;, e);
              }
          }
  
          return SQLiteDatabase.openDatabase(dbFile.getPath(), null, SQLiteDatabase.OPEN_READONLY);
      }
  
      private void copyDatabase(File dbFile) throws IOException {
          InputStream is = context.getAssets().open(DB_PATH+DB_NAME);
          OutputStream os = new FileOutputStream(dbFile);
  
          byte[] buffer = new byte[1024];
          while (is.read(buffer) &gt; 0) {
              os.write(buffer);
          }
  
          os.flush();
          os.close();
          is.close();
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
  
  
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  
      }
  }
  </code></pre>