title: SQLiteException: unknown database
body: <p>I made a custom Adapter for my ListView following <a href="https://droidhat.com/android-listview-using-custom-cursoradapter-sqlite-database" rel="nofollow noreferrer">this tutorial</a>.<br>
  But when I run my app on my device, it gives an error when it's starting.<br>
  The error appears when the <code>onCreate()</code> method of the MainActivity tries to call the <code>getData()</code> method of the NotesDbHelper class.</p>
  
  <p>Can you help me?</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MainActivity extends Activity
  {
  
  private EditText mEditText;
  private Button mButton;
  
  NotesCustomAdapter notesCustomAdapter = null;
  ListView listView = null;
  NotesDbHelper database = null;
  ArrayList&lt;Notes&gt; notes = null;
  
  /** Called when the activity is first created.
   * @param savedInstanceState */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      mButton = (Button) findViewById(R.id.button);
      mEditText = (EditText) findViewById(R.id.editText);
  
      database = new NotesDbHelper(this);
      notes = database.getData();
      notesCustomAdapter= new NotesCustomAdapter(this,R.layout.notes_details,notes);
  
      listView = (ListView) findViewById(R.id.simpleListView);
      listView.setAdapter(notesCustomAdapter);
  
      mButton.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              String input = mEditText.getText().toString();
  
              if (input.length() &gt; 0) {
              database.insertNote(input);
              }
          }
      });
  
      listView.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView&lt;?&gt; a, View v, final int position, long id) {
      AlertDialog.Builder adb=new AlertDialog.Builder(MainActivity.this);
      adb.setTitle("Delete?");
      adb.setMessage("Are you sure you want to delete this note?");
      final int positionToRemove = position;
      adb.setNegativeButton("Cancel", null);
      adb.setPositiveButton("Ok", new AlertDialog.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
              database.deleteNote(which);
              notes.remove(positionToRemove);
              notesCustomAdapter.remove(String.valueOf(positionToRemove));
              notesCustomAdapter.notifyDataSetChanged();
          }});
      adb.show();
      }
  });
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
    }
  }
  </code></pre>
  
  <p>NotesDbHelper.java</p>
  
  <pre><code>public class NotesDbHelper extends SQLiteOpenHelper {
  
      public static final String DATABASE_NAME = "Notes.db";
      public static final String NOTES_TABLE_NAME = "Notes.user";
      public static final String NOTES_COLUMN_ID = "id";
      public static final String NOTES_COLUMN_NAME = "n_text";
  
      public NotesDbHelper(Context context) {
          super(context, DATABASE_NAME, null, 1);
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          db.execSQL("create table  " + NOTES_TABLE_NAME +
                     "(_id integer primary key AUTOINCREMENT NOT NULL," + NOTES_COLUMN_NAME +
                     ")"
          );
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int i, int i1) {
          db.execSQL("DROP TABLE IF EXISTS "+ DATABASE_NAME);
          onCreate(db);
      }
  
      public boolean insertNote(String text) {
          SQLiteDatabase db = this.getWritableDatabase();
          ContentValues contentValues = new ContentValues();
          contentValues.put("n_text", text);
  
          db.insert(NOTES_TABLE_NAME, null, contentValues);
          return true;
      }
  
      public ArrayList&lt;Notes&gt; getData() {
          SQLiteDatabase db = this.getReadableDatabase();
          ArrayList&lt;Notes&gt; notes = new ArrayList&lt;Notes&gt;();
          Cursor result = db.rawQuery("select * from "+ NOTES_TABLE_NAME , null);
          while(result.moveToNext()){
             notes.add( new Notes(result.getString(result.getColumnIndex(NOTES_COLUMN_NAME))));
  
          }
          return notes;
      }
  
      public boolean updateNotes(int id, int text) {
          SQLiteDatabase db = this.getWritableDatabase();
  
          ContentValues contentValues = new ContentValues();
          contentValues.put("n_text", text);
  
          db.update(NOTES_TABLE_NAME, contentValues, "id = ? ", new String[]{Integer.toString(id)});
          return true;
      }
  
      public Integer deleteNote(Integer id) {
          SQLiteDatabase db = this.getWritableDatabase();
          return db.delete(NOTES_TABLE_NAME,
                  "id = ? ",
                  new String[]{Integer.toString(id)});
      }
  
  }
  </code></pre>
  
  <p>Notes.java</p>
  
  <pre><code>    public class Notes {
      String text;
  
      public Notes(String text) {
          this.text = text;
      }
  
      public String getText() {
          return text;
      }
  
      public void setText(String text) {
          this.text = text;
      }
  }
  </code></pre>
  
  <p>NotesCustomAdapter.java</p>
  
  <pre><code>public class NotesCustomAdapter extends ArrayAdapter{
      private Context context;
      private ArrayList&lt;Notes&gt; notes;
  
      public NotesCustomAdapter(Context context, int textViewResourceId, ArrayList objects) {
          super(context,textViewResourceId, objects);
  
          this.context= context;
          notes=objects;
  
      }
  
      private class ViewHolder
      {
          TextView text;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent)
      {
          ViewHolder holder=null;
          if (convertView == null)
          {
              LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = vi.inflate(R.layout.notes_details, null);
  
              holder = new ViewHolder();
              holder.text = (TextView) convertView.findViewById(R.id.text);
              convertView.setTag(holder);
  
          }
          else {
              holder = (ViewHolder) convertView.getTag();
          }
  
          Notes textNotes = notes.get(position);
          holder.text.setText(textNotes.getText());
          return convertView;
      }
  }
  </code></pre>
  
  <p>LogCat</p>
  
  <p>the first line says:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{agenda.com/agenda.com.MainActivity}: android.database.sqlite.SQLiteException: unknown database Notes (code 1): while compiling: create table Notes.user(_id integer primary key AUTOINCREMENT NOT NULL,n_text)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/oEuu7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oEuu7.png" alt="enter image description here"></a></p>