title: What is error no such table: ... in android?
body: <p><img src="https://i.stack.imgur.com/lLPsz.png" alt="enter image description here">I need to show my data on a <code>ListView</code> everything is correct but When i run this project i get this <code>error</code> :</p>
  
  <pre><code>(1) no such table: WebSite_CategoryBack
  </code></pre>
  
  <p>My <code>DataBase</code> is correct .I think that my code has error.</p>
  
  <p>This is my <code>MainActivity.java</code>:</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {   
  public static Context context;
  public static final String DIR_SDCARD =Environment.getExternalStorageDirectory().getAbsolutePath();
  public static final String DIR_DATABASE = DIR_SDCARD + "/Mafatih/";
  DB db = new DB(MainActivity.this);
  public String Titel_Drawer;
  public String messageCursor;
  private ListView mainListView ;
  public SQLiteDatabase  sql;
  public Cursor cursor;
  public ArrayList&lt;String&gt; array;
  private ArrayAdapter&lt;String&gt; listAdapter ;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          File file= new File(DIR_DATABASE);
          file.mkdirs();
          try{
              db.createDataBase();
            }catch (IOException e) {
              Log.e("create DB3", e.toString());
          }
          try{
              db.openDataBase();
             }catch (SQLException e) {
                  Log.e("create DB3", e.toString());
              }
          sql = db.getReadableDatabase();
          cursor = sql.rawQuery("SELECT * FROM WebSite_CategoryBack;", null);
          array = new ArrayList&lt;String&gt;();
          while(cursor.moveToNext()){
              Titel_Drawer = cursor.getString(cursor.getColumnIndex("tittle"));
              array.add(Titel_Drawer);
          }
          cursor.close();
          mainListView = (ListView) findViewById( R.id.mainListView );
          listAdapter = new ArrayAdapter&lt;String&gt;(this, R.layout.drawer_layout_main,R.id.rowTextView_Main, array);
          mainListView.setAdapter( listAdapter );
           mainListView.setOnItemClickListener(new OnItemClickListener() {
               @Override
              public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position,long arg3) {
                  int itemposition = position;
                  String itemvalue = (String) mainListView.getItemAtPosition(position);
                  Toast.makeText(getApplicationContext(),
                          "Position :"+itemposition+"  ListItem : " +itemvalue , Toast.LENGTH_LONG).show();
              }
          });
           mainListView.setTextFilterEnabled(true);
      }
  </code></pre>
  
  <p>And this is my <code>DB.java</code>:</p>
  
  <pre><code>public class DB extends SQLiteOpenHelper{
      public static final String DIR_SDCARD =Environment.getExternalStorageDirectory().getAbsolutePath();
      public static final String DIR_DATABASE = DIR_SDCARD + "/Mafatih/";
  
      private static  String DB_NAME = "Resaleh.db";
  
      private SQLiteDatabase myDataBase;
  
      private final Context myContext;
  
      /**
  * Constructor
  * Takes and keeps a reference of the passed context in order to access to the application assets and resources.
  * @param context
  */
      public DB(Context context) {
  
       super(context, DB_NAME, null, 1);
          this.myContext = context;
      }   
  
    /**
  * Creates a empty database on the system and rewrites it with your own database.
  * */
      public void createDataBase() throws IOException{
  
       boolean dbExist = checkDataBase();
  
       if(dbExist){
       //do nothing - database already exist
       }else{
  
       //By calling this method and empty database will be created into the default system path
       //of your application so we are gonna be able to overwrite that database with our database.
           this.getReadableDatabase();
  
               try {
                      copyDataBase();
  
               } catch (IOException e) {
  
                      throw new Error("Error copying database --&gt; "+e.toString());
  
           }
       }
  
      }
  
      /**
  * Check if the database already exist to avoid re-copying the file each time you open the application.
  * @return true if it exists, false if it doesn't
  */
      private boolean checkDataBase(){
  
       SQLiteDatabase checkDB = null;
  
       try{
       String myPath = DIR_DATABASE + DB_NAME;
       checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
       }catch(SQLiteException e){
           Log.e("asdf", "checkDataBase--&gt;"+e.toString());
       }
  
       if(checkDB != null){
  
       checkDB.close();
  
       }
  
       return checkDB != null ? true : false;
      }
  
      /* (non-Javadoc)
  * @see android.database.sqlite.SQLiteOpenHelper#getReadableDatabase()
  */
  @Override
  public synchronized SQLiteDatabase getReadableDatabase() {
  return super.getReadableDatabase();
  }
  
  
  /**
  * Copies your database from your local assets-folder to the just created empty database in the
  * system folder, from where it can be accessed and handled.
  * This is done by transfering bytestream.
  * */
      private void copyDataBase() throws IOException{
  
       //Open your local db as the input stream
       InputStream myInput = myContext.getAssets().open(DB_NAME);
  
       // Path to the just created empty db
       String outFileName = DIR_DATABASE + DB_NAME;
  
       //Open the empty db as the output stream
       OutputStream myOutput = new FileOutputStream(outFileName);
  
       //transfer bytes from the inputfile to the outputfile
       byte[] buffer = new byte[1024];
       int length;
       try{
       while ((length = myInput.read(buffer))&gt;0){
       myOutput.write(buffer, 0, length);
       }
       }catch (IOException e) {
          Log.e("Copy", e.toString());
      }
  
       //Close the streams
       myOutput.flush();
       myOutput.close();
       myInput.close();
  
      }
  
      public void openDataBase() throws SQLException{
  
       //Open the database
          String myPath = DIR_DATABASE + DB_NAME;
       myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY|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) {
  
  }
  }
  </code></pre>
  
  <p>THANKS.</p>