title: Cannot populate ListView with SQLite database query
body: <p>I'm a complete newbie to Android development. My intention is to create an app which stores user inputs collected in EditText into an SQLite database and then displays them in next activity as a ListView. There are also some buttons involved, some of them are redundant as the app is still in its early stages.</p>
  
  <p>When building the Gradle, there were no errors, also the <code>logcat</code> seemed to be completely OK with the whole thing. The first sign of trouble was checking the <code>/data/data/[projectname]</code> folder which didn't include any <code>.db</code> file or database directory. I have managed to make the transition between activities flawless, but since apparently there's no database in my project, nothing can populate the ListView.</p>
  
  <p>I'm asking for some help determining what's wrong with my code.</p>
  
  <p>MainActivity:</p>
  
  <pre><code>package com.example.peroalex.trackofworkinghours;
  import android.content.Intent;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  
  public class MainActivity extends AppCompatActivity {
  
      MyDatabaseHelper databaseHelper;
  
      Button ADD, DISPLAY, DELETE, MODIFY;
      EditText DESCRIPTION, LOCATION, START, FINISH, COMMENT, ID;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          ADD = (Button) findViewById(R.id.addButton);
          DISPLAY = (Button) findViewById(R.id.displayButton);
          DELETE = (Button) findViewById(R.id.deleteButton);
          MODIFY = (Button) findViewById(R.id.modifyButton);
          DESCRIPTION = (EditText) findViewById(R.id.descriptionEdit);
          LOCATION = (EditText) findViewById(R.id.locationEdit);
          START = (EditText) findViewById(R.id.startEdit);
          FINISH = (EditText) findViewById(R.id.finishEdit);
          COMMENT = (EditText) findViewById(R.id.commentEdit);
          ID = (EditText) findViewById(R.id.idEdit);
  
          databaseHelper = new MyDatabaseHelper(this, null, null, 1);
  
          ADD.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  databaseAddData();
              }
          });
      }
  
      public void databaseAddData() {
  
          String addDSC = DESCRIPTION.getText().toString();
          String addLOC = LOCATION.getText().toString();
          String addSTR = START.getText().toString();
          String addFNS = FINISH.getText().toString();
          String addCOM = COMMENT.getText().toString();
  
          databaseHelper.addData(addDSC, addLOC, addSTR, addFNS, addCOM);
      }
  
      public void Action (View view) {
          Intent intent = new Intent(MainActivity.this, showRecords.class);
          startActivity(intent);
      }
  }
  </code></pre>
  
  <p>MyDatabaseHelper:</p>
  
  <pre><code>package com.example.peroalex.trackofworkinghours;
  import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  /**
   * Created by peroalex on 4/1/18.
   */
  
  public class MyDatabaseHelper extends SQLiteOpenHelper {
  
      //Define database properties
      private static final int database_version = 1;
      private static final String database_name = "DatabaseRecords.db";
      private static final String table_name = "tasks";
      private static final String column_id = "_id";
      private static final String column_desc = "description";
      private static final String column_loc = "location";
      private static final String column_strt = "start";
      private static final String column_fnsh = "finish";
      private static final String column_comm = "comment";
  
  
      public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
      super(context, database_name, factory, database_version);
      }
  
      @Override
      public void onCreate(SQLiteDatabase sqLiteDatabase) {
  
      //This code will be executed when creating a database, it includes the SQLite query which initiates a table
      String query = " CREATE TABLE " + table_name + " ( "
              + column_id + " INTEGER PRIMARY KEY AUTOINCREMENT, "
              + column_desc + " TEXT "
              + column_loc + " TEXT "
              + column_strt + " TEXT "
              + column_fnsh + " TEXT "
              + column_comm + " TEXT " + ");";
      sqLiteDatabase.execSQL(query);
      }
  
  
  
      //This method is used for deleting data according to given ID
      public void removeData(Integer ID) {
      SQLiteDatabase sqLiteDatabase = getWritableDatabase();
      sqLiteDatabase.execSQL("DELETE FROM " + table_name + " WHERE " + column_id + " = " + ID + ";");
      sqLiteDatabase.close();
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
      sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + table_name);
      onCreate(sqLiteDatabase);
      }
  
      //This method is used for adding data to the SQLite database
      public void addData(String dsc, String loc, String st, String fi, String comm) {
      SQLiteDatabase sqLiteDatabase = getWritableDatabase();
  
      ContentValues values = new ContentValues();
  
      values.put(column_desc, dsc);
      values.put(column_loc, loc);
      values.put(column_strt, st);
      values.put(column_fnsh, fi);
      values.put(column_comm, comm);
  
      sqLiteDatabase.insert(table_name, null, values);
      sqLiteDatabase.close();
      }
  
      public Cursor getData() {
      SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
      Cursor data = sqLiteDatabase.rawQuery("SELECT * FROM " + table_name, null);
      return data;
      }
  }
  </code></pre>
  
  <p>showRecords:</p>
  
  <pre><code>package com.example.peroalex.trackofworkinghours;
  import android.database.Cursor;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.widget.ArrayAdapter;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  
  import java.util.ArrayList;
  
  
  /**
   * Created by peroalex on 4/2/18.
   */
  
  public class showRecords extends AppCompatActivity {
  
      ListView listView;
      MyDatabaseHelper myDatabaseHelper;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_show_records);
  
      listView = (ListView) findViewById(R.id.displayDBListview);
      myDatabaseHelper = new MyDatabaseHelper(this, null, null, 1);
      displayDB();
      }
  
      public void displayDB() {
      Cursor data = myDatabaseHelper.getData();
      ArrayList&lt;String&gt; listData = new ArrayList&lt;&gt;();
      while (data.moveToNext()) {
          listData.add(data.getString(1));
      }
  
      ListAdapter adapter = new ArrayAdapter&lt;&gt;(this, android.R.layout.simple_list_item_1, listData);
      listView.setAdapter(adapter);
      }
  }
  </code></pre>
  
  <p>activity_main:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.peroalex.trackofworkinghours.MainActivity"&gt;
  
      &lt;EditText
      android:id="@+id/descriptionEdit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:drawableStart="@drawable/ic_description_black_24dp"
      android:ems="10"
      android:fontFamily="serif"
      android:hint="@string/description"
      android:inputType="text"
      android:textAlignment="center"
      android:textSize="16sp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.052" /&gt;
  
      &lt;EditText
      android:id="@+id/locationEdit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:drawableStart="@drawable/ic_location_on_black_24dp"
      android:ems="10"
      android:fontFamily="serif"
      android:hint="@string/location"
      android:inputType="text"
      android:textAlignment="center"
      android:textSize="16sp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.14" /&gt;
  
      &lt;EditText
      android:id="@+id/startEdit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:drawableStart="@drawable/ic_work_black_24dp"
      android:ems="10"
      android:fontFamily="serif"
      android:hint="@string/start"
      android:inputType="time"
      android:textAlignment="center"
      android:textSize="16sp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.249" /&gt;
  
      &lt;EditText
      android:id="@+id/finishEdit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:drawableStart="@drawable/ic_work_black_24dp"
      android:ems="10"
      android:fontFamily="serif"
      android:hint="@string/finish"
      android:inputType="time"
      android:textAlignment="center"
      android:textSize="16sp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.337" /&gt;
  
      &lt;EditText
      android:id="@+id/commentEdit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:drawableStart="@drawable/ic_comment_black_24dp"
      android:ems="10"
      android:fontFamily="serif"
      android:hint="@string/comments"
      android:inputType="textMultiLine"
      android:textAlignment="center"
      android:textSize="16sp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.448" /&gt;
  
      &lt;Button
      android:id="@+id/addButton"
      style="@android:style/Widget.Holo.Button"
      android:layout_width="90sp"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:text="@string/add"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.297"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.628" /&gt;
  
      &lt;Button
      android:id="@+id/deleteButton"
      style="@android:style/Widget.Holo.Button.Borderless"
      android:layout_width="80sp"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:text="@string/delete"
      android:textColor="@android:color/black"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.291"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.934" /&gt;
  
      &lt;Button
      android:id="@+id/displayButton"
      style="@android:style/Widget.Holo.Button"
      android:layout_width="90sp"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:text="@string/display"
      android:onClick="Action"
      android:textColor="@android:color/white"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.702"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.628" /&gt;
  
      &lt;Button
      android:id="@+id/modifyButton"
      style="@android:style/Widget.Holo.Button.Borderless"
      android:layout_width="80sp"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:text="@string/modify"
      android:textColor="@android:color/black"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.708"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.934" /&gt;
  
      &lt;TextView
      android:id="@+id/textView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:text="@string/insert_an_id_to_either_modify_or_delete_the_query"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.731" /&gt;
  
      &lt;EditText
      android:id="@+id/idEdit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:ems="10"
      android:drawableStart="@drawable/ic_update_black_24dp"
      android:fontFamily="serif"
      android:hint="@string/id"
      android:inputType="text"
      android:textAlignment="center"
      android:textSize="16sp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.829" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>activity_show_records:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;ListView
      android:id="@+id/displayDBListview"
      android:layout_width="344dp"
      android:layout_height="551dp"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" /&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>