title: showing data in listview from database in android studio
body: <p>So I tried creating a database and the data is getting saved on the database but I wanted to get the data in the list view on the mainactivity so I tried here's the <strong>Main Activity</strong></p>
  
  <pre><code> import android.content.Intent;
   import android.database.Cursor;
   import android.database.sqlite.SQLiteDatabase;
   import android.database.sqlite.SQLiteOpenHelper;
   import android.support.design.widget.FloatingActionButton;
   import android.support.v7.app.AppCompatActivity;
   import android.os.Bundle;
   import android.view.View;
   import android.widget.ArrayAdapter;
   import android.widget.ListAdapter;
   import android.widget.ListView;
   import android.widget.Toast;
  
   import java.util.ArrayList;
   import java.util.List;
  
   import static com.frolicfreak.bhushan.memo.DatabaseHelper.Table_Name;
  
  public class MainActivity extends AppCompatActivity implements View.OnClickListener{
  
  FloatingActionButton fab;
  DatabaseHelper db;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      db =new DatabaseHelper(this);
  
      fab= (FloatingActionButton)findViewById(R.id.fab);
      fab.setOnClickListener(this);
  
      ListView listView = (ListView)findViewById(R.id.list);
  
      ArrayList&lt;String&gt; theList =new ArrayList&lt;&gt;();
      Cursor data= db.getAllData();
  
      if (data.getCount()==0){
          return;
      }
      else
      {
          while(data.moveToNext()){
              theList.add(getString(1));
              ListAdapter listAdapter=new ArrayAdapter&lt;&gt;(this,android.R.layout.simple_list_item_1,theList);
              listView.setAdapter(listAdapter);
          }
      }
  }
  
  @Override
  public void onClick(View v) {
  
      Intent intent= new Intent(this,Main2Activity.class);
      startActivity(intent);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>now I executed this activity and there is an error in the android monitor</p>
  
  <pre><code>  08-25 02:13:23.179 4125-4125/com.frolicfreak.bhushan.memo E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          Process: com.frolicfreak.bhushan.memo, PID: 4125
                                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.frolicfreak.bhushan.memo/com.frolicfreak.bhushan.memo.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x1
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                              at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:148)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                           Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
                                                                              at android.content.res.Resources.getText(Resources.java:312)
                                                                              at android.content.res.Resources.getString(Resources.java:400)
                                                                              at android.content.Context.getString(Context.java:409)
                                                                              at com.frolicfreak.bhushan.memo.MainActivity.onCreate(MainActivity.java:47)
                                                                              at android.app.Activity.performCreate(Activity.java:6237)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                              at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:148) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>
  
  <p>the application is getting crashed even in the main launch activity 
  so please help me solving this problem</p>
  
  <p>yes the database helper file is extended 
  <strong>DatabaseHelper</strong> java file is as follows</p>
  
  <pre><code>    package com.frolicfreak.bhushan.memo;
  
      import android.content.ContentValues;
      import android.content.Context;
      import android.database.Cursor;
      import android.database.sqlite.SQLiteDatabase;
      import android.database.sqlite.SQLiteOpenHelper;
  
      import java.util.ArrayList;
  
      /**
   * Created by BHUSHAN on 24-08-2017.
  */
  
       public class DatabaseHelper extends SQLiteOpenHelper {
  
  public static final String Database_Name = "Memo.db";
  public static final String Table_Name = "Memo";
  public static final String col1 = "ID";
  public static final String col2 = "data";
  
  
  public DatabaseHelper(Context context) {
      super(context, Database_Name, null, 1);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
  
      db.execSQL("create table " + Table_Name + "(ID integer primary key autoincrement, data text)");
  
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      db.execSQL("drop table if exists " + Table_Name);
      onCreate(db);
  }
  
  public boolean insertData(String data, String Data) {
      SQLiteDatabase db = this.getWritableDatabase();
      ContentValues contentValues = new ContentValues();
      contentValues.put(col2, Data);
      long result = db.insert(Table_Name, null, contentValues);
      if (result==-1)
          return false;
      else
          return true;
  }
  
  public Cursor getAllData() {
  
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor res = db.rawQuery("SELECT * FROM " + Table_Name, null);
      return res;
  }
  </code></pre>
  
  <p>}</p>