title: updating and deleting row in listview
body: <p>I know the question is not new, but all the other examples I found here didnt work. Thats why I am writing to you.</p>
  
  <p>I created a book application, where you can save bookdata from googlebooks and can save the data into an sqlite db. The bookdata will be displayed in a listview.
  If you click on a row, all the data of the row will be displayed in EdittExts in another activity - Looks like Detailed book view. 
  Some example pictures: <a href="http://i.stack.imgur.com/666uZ.png" rel="nofollow">Listview</a> ; <a href="http://i.stack.imgur.com/eoYiB.png" rel="nofollow">detailed bookview </a></p>
  
  <p>Now I want to give the possibility to the user to edit these bookinfos.
  I implemented some code to update and delte the info and I get the info from the Logcat, that the Db is created but when I go back to the ListView no Data is updated or deleted. </p>
  
  <p>I used a video called "Android Studio Tutorial - 37 - Update Database" from youtube to convert for my solution </p>
  
  <p>Maybe you can help me.</p>
  
  <p>Following my code for the Book Info:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_book_info);
          bookDBHelper = new BookDBHelper(this);
          Typeface myTypeface = Typeface.createFromAsset(getAssets(), "Lobster.ttf");
          TextView myTextView = (TextView) findViewById(R.id.yourbookinfo);
          myTextView.setTypeface(myTypeface);
  
          btn_update = (Button) findViewById(R.id.button_update);
  
          Intent intent = getIntent();
  
          String secret_title = intent.getStringExtra(BookDataListActivity.EXTRA_MSG1);
          Secret_editText_title = (EditText) findViewById(R.id.secret_edittext_title);
          Secret_editText_title.setText(secret_title);
  
          String book_title = intent.getStringExtra(BookDataListActivity.EXTRA_MSG1);
          passedbooktitle = (EditText) findViewById(R.id.passed_booktitle);
          passedbooktitle.setText(book_title);
  
          String book_author = intent.getStringExtra(BookDataListActivity.EXTRA_MSG2);
          passedbookauthor = (EditText) findViewById(R.id.passed_bookauthor);
          passedbookauthor.setText(book_author);
  
          String book_date = intent.getStringExtra(BookDataListActivity.EXTRA_MSG3);
          passedbookdate = (EditText) findViewById(R.id.passed_bookdate);
          passedbookdate.setText(book_date);
  
          String book_rating = intent.getStringExtra(BookDataListActivity.EXTRA_MSG4);
          passedbookrating = (EditText) findViewById(R.id.passed_bookrating);
          passedbookrating.setText(book_rating);
  
          String book_shelf = intent.getStringExtra(BookDataListActivity.EXTRA_MSG5);
          passedbookshelf = (EditText) findViewById(R.id.passed_bookshelf);
          passedbookshelf.setText(book_shelf);
  
      }
  
  
      public void updateBookInfo(View view){
          bookDBHelper = new BookDBHelper(getApplicationContext());
          sqLiteDatabaseBooks = bookDBHelper.getWritableDatabase();
  
          secret_editText_titel = Secret_editText_title.getText().toString();
  
          String booktitle, bookauthor, bookdate, bookrating, bookshelf;
          booktitle = passedbooktitle.getText().toString();
          bookauthor = passedbookauthor.getText().toString();
          bookdate = passedbookdate.getText().toString();
          bookrating = passedbookrating.getText().toString();
          bookshelf = passedbookshelf.getText().toString();
          int count = bookDBHelper.updateEditedBookInfo(secret_editText_titel,
                  booktitle,bookauthor, bookdate, bookrating, bookshelf, sqLiteDatabaseBooks);
          Toast.makeText(getApplicationContext(), count+" book updated", Toast.LENGTH_LONG).show();
          finish();
  
      }
  
      public void deleteBook(View view){
          bookDBHelper = new BookDBHelper(getApplicationContext());
          sqLiteDatabaseBooks = bookDBHelper.getWritableDatabase();
          bookDBHelper.deleteBookInformation(secret_editText_titel, sqLiteDatabaseBooks);
          Toast.makeText(getBaseContext(), "Book deleted", Toast.LENGTH_LONG).show();
      }
  </code></pre>
  
  <p>And for my BookDBHelper:</p>
  
  <pre><code>public int updateEditedBookInfo(String old_title, String new_title, String new_author,
                                       String new_date, String new_rating,
                                       String new_shelf, SQLiteDatabase sqLiteDatabase){
          ContentValues contentValues = new ContentValues();
          contentValues.put(BookContent.NewBookInfo.BOOK_TITLE, new_title);
          contentValues.put(BookContent.NewBookInfo.BOOK_AUTHOR, new_author);
          contentValues.put(BookContent.NewBookInfo.BOOK_DATE, new_date);
          contentValues.put(BookContent.NewBookInfo.BOOK_RATING, new_rating);
          contentValues.put(BookContent.NewBookInfo.BOOK_SHELF, new_shelf);
  
          String selection = BookContent.NewBookInfo.BOOK_TITLE + " = ?";
          String [] selection_args = {old_title};
          int count =  sqLiteDatabase.update(BookContent.NewBookInfo.TABLE_NAME_BOOKS, contentValues, selection, selection_args);
          return count;
      }
  
      public void deleteBookInformation(String book_title,SQLiteDatabase sqLiteDatabase){
      String selection = BookContent.NewBookInfo.BOOK_TITLE+ "  =?";
      String [] selection_args = {book_title};
      sqLiteDatabase.delete(BookContent.NewBookInfo.TABLE_NAME_BOOKS, selection, selection_args);
  }
  </code></pre>
  
  <p><strong>Edit as asked activity_book_info.XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.kasutwentyseven.gui4selfshelf.Books.BookInfoActivity"
      android:background="@color/Background"&gt;
  
      &lt;TextView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/yourbookinfo"
          android:id="@+id/yourbookinfo"
          android:textSize="25dp"
          android:textColor="@color/Textcolor"
          android:gravity="center_horizontal"
          android:textStyle="bold"
          /&gt;
  
      &lt;LinearLayout
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/yourbookinfo"
          android:layout_alignParentStart="true"
          android:id="@+id/linearLayout5"&gt;
  
          &lt;LinearLayout
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;ImageView
                  android:layout_width="100dp"
                  android:layout_height="match_parent"
                  android:id="@+id/passed_bookimage" /&gt;
  
              &lt;LinearLayout
                  android:orientation="vertical"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"&gt;
  
                  &lt;EditText
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:id="@+id/passed_booktitle" /&gt;
  
                  &lt;EditText
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:id="@+id/passed_bookauthor" /&gt;
  
                  &lt;EditText
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:id="@+id/passed_bookdate" /&gt;
  
                  &lt;EditText
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:id="@+id/passed_bookrating" /&gt;
  
                  &lt;EditText
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:id="@+id/passed_bookshelf" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/linearLayout5"
          android:layout_alignParentStart="true"
          android:id="@+id/linearLayout6"&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/btn_update"
              android:id="@+id/button_update"
              android:onClick="updateBookInfo"/&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/btn_delete"
              android:id="@+id/btn_delete_book"
              android:onClick="deleteBook"/&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/linearLayout6"&gt;
  
          &lt;EditText
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/secret_edittext_title" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>