title: unable to open database Sqlite file
body: <p>I found a lot of question about this problem, but I can't fix it. I have a sqlite db in assets folder:</p>
  
  <pre><code>assets/data/data/{package_name}/databases/dbtest.sqlite
  </code></pre>
  
  <p>I tried to:</p>
  
  <ol>
  <li>Uninstall the project</li>
  <li>Clean the project</li>
  <li>Refresh and also restarted the ecilipse</li>
  <li>i checked my package name</li>
  <li>i checked my db file name</li>
  </ol>
  
  <p>But i cant able to solve it. I dont know where i am wrong.</p>
  
  <p>Thanks in Advance</p>
  
  <p><strong>DBHelper.java</strong></p>
  
  <pre><code>public class DBHelper extends SQLiteOpenHelper {
  
      private static String DB_PATH = "/data/data/com.exasmple.dbexam/databases/";
      private static String DB_NAME = "dbtest.sqlite";
      public static final String APP_TABLE = "land";
  
      private static final int DATABASE_VER5ION = 1;
      private static final String TYPE = "type";
      private static final String ID = "id";
  
      private SQLiteDatabase myDataBase;
      private final Context myContext;
      public static String state;
  
      public DBHelper(Context context) {
          super(context, DB_NAME, null, DATABASE_VER5ION);
          this.myContext = context;
      }
  
      public void createDataBase() throws IOException {
          // System.out.println("Creating database");
          boolean dbExist = checkDataBase();
          if (!dbExist) {
              this.getReadableDatabase();
  
              try {
                  copyDataBase();
              } catch (IOException e) {
                  throw new Error("Error copying database");
              }
          }
      }
  
      private boolean checkDataBase() {
          SQLiteDatabase checkDB = null;
          try {
              String myPath = DB_PATH + DB_NAME;
              checkDB = SQLiteDatabase.openDatabase(myPath, null,
                      SQLiteDatabase.OPEN_READONLY);
          } catch (SQLiteException e) {
  
          }
          if (checkDB != null) {
              checkDB.close();
          }
  
          return checkDB != null ? true : false;
      }
  
      private void copyDataBase() throws IOException {
  
          InputStream myInput = myContext.getAssets().open(DB_NAME);
  
          String outFileName = DB_PATH + DB_NAME;
  
          OutputStream myOutput = new FileOutputStream(outFileName);
  
          byte[] buffer = new byte[1024];
          int length;
          while ((length = myInput.read(buffer)) &gt; 0) {
              myOutput.write(buffer, 0, length);
          }
  
  
          myOutput.flush();
          myOutput.close();
          myInput.close();
          System.out.println("Database copied into system data");
  
      }
  
      public void openDataBase() throws SQLException {
  
          System.out.println("Open database");
          String myPath = DB_PATH + DB_NAME;
          myDataBase = SQLiteDatabase.openDatabase(myPath, null,
                  SQLiteDatabase.OPEN_READWRITE);// SQLiteDatabase.NO_LOCALIZED_COLLATORS);
  
      }
  
      @Override
      public synchronized void close() {
          if (myDataBase != null)
              myDataBase.close();
          super.close();
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
  
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  
          db.execSQL("DROP TABLE IF EXISTS report");
          db.execSQL("DROP TABLE IF EXISTS appstatus");
          onCreate(db);
      }
  
      public ArrayList&lt;String&gt; GetGroupName() {
          String sql = "";
          // System.out.println("Inside Database");
          sql = "select chapterid from content";
  
          ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  
          Cursor cursor = myDataBase.rawQuery(sql, null);
  
          try {
              if (cursor != null) {
                  if (cursor.moveToFirst()) {
                      do {
                          list.add(cursor.getString(0));
                          System.out.println("dblist value==" + list);
                      } while (cursor.moveToNext());
                  }
                  if (cursor != null &amp;&amp; !cursor.isClosed()) {
                      cursor.close();
                  }
              } else
                  Toast.makeText(myContext, "No values in DB", Toast.LENGTH_SHORT)
                          .show();
          } catch (Exception e) {
              System.out.println("GetGradeNames(): " + e);
          }
          return list;
      }
  
  }
  </code></pre>
  
  <p><strong>Logcat :</strong></p>
  
  <pre><code>07-09 14:57:27.834: E/AndroidRuntime(987): FATAL EXCEPTION: main
  07-09 14:57:27.834: E/AndroidRuntime(987): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exasmple.dbexam/com.exasmple.dbexam.MainActivity}: android.database.sqlite.SQLiteException: unable to open database file
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.os.Handler.dispatchMessage(Handler.java:99)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.os.Looper.loop(Looper.java:130)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at java.lang.reflect.Method.invokeNative(Native Method)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at java.lang.reflect.Method.invoke(Method.java:507)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at dalvik.system.NativeStart.main(Native Method)
  07-09 14:57:27.834: E/AndroidRuntime(987): Caused by: android.database.sqlite.SQLiteException: unable to open database file
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.database.sqlite.SQLiteDatabase.&lt;init&gt;(SQLiteDatabase.java:1849)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at com.exasmple.dbexam.DBHelper.openDataBase(DBHelper.java:138)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at com.exasmple.dbexam.MainActivity.onCreate(MainActivity.java:21)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  07-09 14:57:27.834: E/AndroidRuntime(987):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  07-09 14:57:27.834: E/AndroidRuntime(987):  ... 11 more
  </code></pre>