title: Not work android application after connect sqlite database
body: <p>I am developing sample android application with connecting sqlite database. I can't see real interface it because of error displaying. Not display any thing for it and some time display also is not responded. It is not displaying any error but android device display image <a href="https://i.stack.imgur.com/aaoih.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aaoih.png" alt="enter image description here"></a> also I am add my code below. 
  Myactivity.java class</p>
  
  <pre><code>package com.example.randikawann.androidconnectsqlite;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.TextView;
  
  
  public class MainActivity extends AppCompatActivity {
      EditText userInput;
      TextView userText;
      MyDBHandler myDBHandler;
      private static final String TAG = "MyActivity";
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          userInput = (EditText) findViewById(R.id.user_input);
          userText = (TextView) findViewById(R.id.user_text);
          myDBHandler=new MyDBHandler(this,null,null,1);
          printDatabase();
          Log.i(TAG, "start application");
      }
  
      public void addButtonClicked(View view){
          Products products=new Products(userInput.getText().toString());
          myDBHandler.addProduct(products);
          printDatabase();
          Log.i(TAG, "add button clicked");
      }
  
      public void deleteButtonClicked(View view){
          String inputText=userInput.getText().toString();
          myDBHandler.deleteproduct(inputText);
          printDatabase();
          Log.i(TAG, "delete button clicked");
      }
      private void printDatabase() {
          String dbString =myDBHandler.databaseToString();
          userText.setText(dbString);
          userInput.setText("");
          Log.i(TAG, "print database");
      }
      @Override
      protected void onDestroy() {
          myDBHandler.close();
          super.onDestroy();
      }
  }
  </code></pre>
  
  <p>this is MyDBHandler.java class</p>
  
  <pre><code>package com.example.randikawann.androidconnectsqlite;
  
  import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  public class MyDBHandler extends SQLiteOpenHelper{
      private static final int DATABASE_VERSION=1;
      private static final String DATABASE_NAME="products.db";
      private static final String TABLE_PRODUCTS="products";
      private static final String COLUMN_ID="id";
      private static final String COLUMN_PRODUCTNAME="productname";
  
      public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
          super(context, DATABASE_NAME, factory,version);
      }
      @Override
      public void onCreate(SQLiteDatabase db) {
          String query = "CREATE TABLE " + TABLE_PRODUCTS + "(" +
                  COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                  COLUMN_PRODUCTNAME + " TEXT " +
                  ");";
          db.execSQL(query);
  
      }
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          db.execSQL("DROP TABLE IF EXISTS "+ TABLE_PRODUCTS);
          onCreate(db);
      }
      //add a new row to database
      public void addProduct(Products products){
          SQLiteDatabase db=getWritableDatabase();
          ContentValues values=new ContentValues();
          values.put(COLUMN_PRODUCTNAME,products.get_productname());
          db.insert(TABLE_PRODUCTS,null,values);
          db.close();
      }
      //delect a row in database
      public void deleteproduct(String productName){
          SQLiteDatabase db=getWritableDatabase();
          String query="DELETE FROM "+ TABLE_PRODUCTS + " WHERE " + COLUMN_PRODUCTNAME + "=\"" + productName +"\";" ;
          db.execSQL(query);
      }
      //printout database as a string
      public String databaseToString(){
          String dbString = "";
          SQLiteDatabase db = this.getWritableDatabase();
          String query="SELECT * FROM " + TABLE_PRODUCTS + " WHERE 1";
  
  
          //cursor point to  a location in your result
          Cursor c=db.rawQuery(query, null);
          //move to first row in your results
          c.moveToFirst();
  
          while (!c.isAfterLast()){
              if (c.getString(c.getColumnIndex("productname"))!=null){
                  dbString +=c.getString(c.getColumnIndex("productname"));
                  dbString +="\n";
              }
          }
          db.close();
          return dbString;
      }
  
  
  
  
  }
  </code></pre>
  
  <p>Products.java class is</p>
  
  <pre><code>package com.example.randikawann.androidconnectsqlite;
  
  public class Products {
      private int _id;
      private String _productname;
  
      public Products() {
      }
  
      public Products(String productname) {
          this._productname = productname;
      }
  
      public int get_id() {
          return _id;
      }
  
      public String get_productname() {
          return _productname;
      }
  
      public void set_id(int _id) {
          this._id = _id;
      }
  
      public void set_productname(String _productname) {
          this._productname = _productname;
      }
  }
  </code></pre>
  
  <p>also I am adding xml file call as activity main.xml</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=".MainActivity"&gt;
  
      &lt;TextView
          android:id="@+id/user_text"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="150dp"
          android:layout_marginStart="150dp"
          android:layout_marginTop="250dp"
          android:text="Hello World!"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;Button
          android:id="@+id/add_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="50dp"
          android:layout_marginStart="50dp"
          android:layout_marginTop="150dp"
          android:onClick="addButtonClicked"
          android:text="Add"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;Button
          android:id="@+id/delete_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginEnd="50dp"
          android:layout_marginRight="50dp"
          android:layout_marginTop="150dp"
          android:onClick="deleteButtonClicked"
          android:text="Delete"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;EditText
          android:id="@+id/user_input"
          android:layout_width="262dp"
          android:layout_height="wrap_content"
          android:layout_marginLeft="62dp"
          android:layout_marginStart="62dp"
          android:layout_marginTop="86dp"
          android:ems="10"
          android:inputType="textPersonName"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>