title: android.database.sqlite.SQLiteException: no such table: yoga (code 1 SQLITE_ERROR):
body: <p>I am trying to create an app. App is opening in Emulator. But when I am trying to open the app in real device, it is crashing. I tried many solutions regarding my problem. but I am unable to solve my problem. I added DatabaseHelper, Logcat. I added android.permission in AndroidManifest.xml but failed to get solution. App is not opening. Application terminated. not opening. Please suggest to solve this problem.</p>
  
  <p>I deleted the app before running the app in real device. But problem remains same.</p>
  
  <p><strong>DatabaseHelper.java</strong></p>
  
  <pre><code>public class DatabaseHelper extends SQLiteOpenHelper {
      private static DatabaseHelper mInstance = null;
  
  
      String DB_PATH = null;
      private static String DB_NAME = "kriyayoga.db";
      private static SQLiteDatabase myDataBase;
      private  final Context myContext;
      private  static  final int DATABASE_VERSION = 1;
  
      public static synchronized DatabaseHelper getInstance(Context context) {
  
          if (mInstance == null) {
              mInstance = new DatabaseHelper(context.getApplicationContext());
          }
          return mInstance;
      }
  
      public DatabaseHelper(Context context) {
          super(context, DB_NAME, null, DATABASE_VERSION);
          this.myContext = context;
          this.DB_PATH = "/data/data/" + context.getPackageName() + "/" + "databases/";
          //this.DB_PATH = this.myContext.getDatabasePath(DB_NAME).getAbsolutePath();
          Log.e("Path 1", DB_PATH);
  
      }
  
  
      public void createDataBase() throws IOException {
          boolean dbExist = checkDataBase();
          if (dbExist) {
          } else {
              this.getReadableDatabase();
              try {
                  copyDataBase();
              } catch (IOException e) {
                  throw new Error("Error copying database");
              }
          }
      }
  
      private boolean checkDataBase() {
          File dbFile = myContext.getDatabasePath(DB_NAME);
          return dbFile.exists();
      }
  
      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();
  
      }
  
      public void openDataBase() throws SQLException {
          String myPath = DB_PATH + DB_NAME;
          myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
  
      }
  
      @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) {
          if (newVersion &gt; oldVersion)
              try {
                  copyDataBase();
              } catch (IOException e) {
                  e.printStackTrace();
  
              }
      }
  
      @Override
      public void onOpen(SQLiteDatabase db) {
          onCreate(db);
      }
  
  }
  </code></pre>
  
  <p><strong>Logcat</strong> Problem shows at ListNavAdapter.java</p>
  
  <pre><code>E/SQLiteLog: (1) no such table: yoga
  D/AndroidRuntime: Shutting down VM
  E/AndroidRuntime: FATAL EXCEPTION: main
      android.database.sqlite.SQLiteException: no such table: yoga (code 1 SQLITE_ERROR): , while compiling: SELECT heading FROM yoga ORDER BY _id
          at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
          at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:946)
          at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:527)
          at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
          at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:58)
          at android.database.sqlite.SQLiteQuery.&lt;init&gt;(SQLiteQuery.java:37)
          at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
          at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1408)
          at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1347)
          at com.priyanka.kriyayoga.ListNavAdapter.onViewCreated(ListNavAdapter.java:81)
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1471)
          at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
          at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
          at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
          at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
          at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
          at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
          at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273)
          at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
          at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
          at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:620)
          at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
          at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1395)
          at android.app.Activity.performStart(Activity.java:7293)
          at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3196)
          at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
          at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
          at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2011)
          at android.os.Handler.dispatchMessage(Handler.java:106)
          at android.os.Looper.loop(Looper.java:224)
          at android.app.ActivityThread.main(ActivityThread.java:7135)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
  </code></pre>
  
  <p>When I am running the app in real device it says <strong>runtime exception</strong></p>
  
  <p>App is experiencing crashes.</p>
  
  <p>in <strong>AndroidManifest.xml</strong> I added</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>In <strong>ListNavAdapter</strong> I used to get data</p>
  
  <pre><code>SQLiteDatabase sqLiteDatabase = DatabaseHelper.getInstance(this.getContext()).getReadableDatabase();
   Cursor cursor1 = sqLiteDatabase.rawQuery("SELECT heading FROM yoga ORDER BY _id", new String[]{});
  </code></pre>