title: Edittext with suggested text from corresponding row in database
body: <p>Okay, this time as in title I need to have text suggestion in edittext BUT the suggestion must be pulled from the corresponding row in database. 
  I have database set with 48 rows. No rows can be added as I disabled this functionality. Rows can be only updated. User must have an option to retain current content from the corresponding row or type a new content. </p>
  
  <p>Does anybody have an idea how this could be achieved?
  Thanks in advance.
  Paddy</p>
  
  <p>Edit----------------------------------------------------------------------------------------</p>
  
  <p>here is my Diary file:</p>
  
  <pre><code>package com.example.classorganizer;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.database.Cursor;
  import android.os.Bundle;
  import android.support.v4.widget.SimpleCursorAdapter;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.AutoCompleteTextView;
  import android.widget.Button;
  import android.widget.EditText;
  
  import com.cookbook.data.MyDB;
  public class Diary extends Activity {
      AutoCompleteTextView titleET1;
      AutoCompleteTextView titleET2;
      AutoCompleteTextView titleET3;
      AutoCompleteTextView titleET4;
      AutoCompleteTextView titleET5;
      AutoCompleteTextView titleET6;
      AutoCompleteTextView titleET7;
      AutoCompleteTextView titleET8;
      AutoCompleteTextView titleET9;
      AutoCompleteTextView titleET10;
      AutoCompleteTextView titleET11;
      AutoCompleteTextView titleET12;
      AutoCompleteTextView titleET13;
      AutoCompleteTextView titleET14;
      AutoCompleteTextView titleET15;
      AutoCompleteTextView titleET16;
      AutoCompleteTextView titleET17;
      AutoCompleteTextView titleET18;
      AutoCompleteTextView titleET19;
      AutoCompleteTextView titleET20;
      AutoCompleteTextView titleET21;
      AutoCompleteTextView titleET22;
      AutoCompleteTextView titleET23;
      AutoCompleteTextView titleET24;
      AutoCompleteTextView titleET25;
      AutoCompleteTextView titleET26;
      AutoCompleteTextView titleET27;
      AutoCompleteTextView titleET28;
      AutoCompleteTextView titleET29;
      AutoCompleteTextView titleET30;
      AutoCompleteTextView titleET31;
      AutoCompleteTextView titleET32;
      AutoCompleteTextView titleET33;
      AutoCompleteTextView titleET34;
      AutoCompleteTextView titleET35;
      AutoCompleteTextView titleET36;
      AutoCompleteTextView titleET37;
      AutoCompleteTextView titleET38;
      AutoCompleteTextView titleET39;
      AutoCompleteTextView titleET40;
      AutoCompleteTextView titleET41;
      AutoCompleteTextView titleET42;
      AutoCompleteTextView titleET43;
      AutoCompleteTextView titleET44;
      AutoCompleteTextView titleET45;
      AutoCompleteTextView titleET46;
      AutoCompleteTextView titleET47;
      AutoCompleteTextView titleET48;
  
      Button submitBT;
      MyDB dba;
  
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
  
  
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.diary);
          dba = new MyDB(this);
          dba.open();
  
  
  
  titleET1 = (AutoCompleteTextView)findViewById(R.id.diary1);
  
          titleET2 = (AutoCompleteTextView)findViewById(R.id.diary2);
          titleET3 = (AutoCompleteTextView)findViewById(R.id.diary3);
          titleET4 = (AutoCompleteTextView)findViewById(R.id.diary4);
          titleET5 = (AutoCompleteTextView)findViewById(R.id.diary5);
          titleET6 = (AutoCompleteTextView)findViewById(R.id.diary6);
          titleET7 = (AutoCompleteTextView)findViewById(R.id.diary7);
          titleET8 = (AutoCompleteTextView)findViewById(R.id.diary8);
          titleET9 = (AutoCompleteTextView)findViewById(R.id.diary9);
          titleET10 = (AutoCompleteTextView)findViewById(R.id.diary10);
          titleET11 = (AutoCompleteTextView)findViewById(R.id.diary11);
          titleET12 = (AutoCompleteTextView)findViewById(R.id.diary12);
          titleET13 = (AutoCompleteTextView)findViewById(R.id.diary13);
          titleET14 = (AutoCompleteTextView)findViewById(R.id.diary14);
          titleET15 = (AutoCompleteTextView)findViewById(R.id.diary15);
          titleET16 = (AutoCompleteTextView)findViewById(R.id.diary16);
          titleET17 = (AutoCompleteTextView)findViewById(R.id.diary17);
          titleET18 = (AutoCompleteTextView)findViewById(R.id.diary18);
          titleET19 = (AutoCompleteTextView)findViewById(R.id.diary19);
          titleET20 = (AutoCompleteTextView)findViewById(R.id.diary20);
          titleET21 = (AutoCompleteTextView)findViewById(R.id.diary21);
          titleET22 = (AutoCompleteTextView)findViewById(R.id.diary22);
          titleET23 = (AutoCompleteTextView)findViewById(R.id.diary23);
          titleET24 = (AutoCompleteTextView)findViewById(R.id.diary24);
          titleET25 = (AutoCompleteTextView)findViewById(R.id.diary25);
          titleET26 = (AutoCompleteTextView)findViewById(R.id.diary26);
          titleET27 = (AutoCompleteTextView)findViewById(R.id.diary27);
          titleET28 = (AutoCompleteTextView)findViewById(R.id.diary28);
          titleET29 = (AutoCompleteTextView)findViewById(R.id.diary29);
          titleET30 = (AutoCompleteTextView)findViewById(R.id.diary30);
          titleET31 = (AutoCompleteTextView)findViewById(R.id.diary31);
          titleET32 = (AutoCompleteTextView)findViewById(R.id.diary32);
          titleET33 = (AutoCompleteTextView)findViewById(R.id.diary33);
          titleET34 = (AutoCompleteTextView)findViewById(R.id.diary34);
          titleET35 = (AutoCompleteTextView)findViewById(R.id.diary35);
          titleET36 = (AutoCompleteTextView)findViewById(R.id.diary36);
          titleET37 = (AutoCompleteTextView)findViewById(R.id.diary37);
          titleET38 = (AutoCompleteTextView)findViewById(R.id.diary38);
          titleET39 = (AutoCompleteTextView)findViewById(R.id.diary39);
          titleET40 = (AutoCompleteTextView)findViewById(R.id.diary40);
          titleET41 = (AutoCompleteTextView)findViewById(R.id.diary41);
          titleET42 = (AutoCompleteTextView)findViewById(R.id.diary42);
          titleET43 = (AutoCompleteTextView)findViewById(R.id.diary43);
          titleET44 = (AutoCompleteTextView)findViewById(R.id.diary44);
          titleET45 = (AutoCompleteTextView)findViewById(R.id.diary45);
          titleET46 = (AutoCompleteTextView)findViewById(R.id.diary46);
          titleET47 = (AutoCompleteTextView)findViewById(R.id.diary47);
          titleET48 = (AutoCompleteTextView)findViewById(R.id.diary48);
  
  
  
  
          submitBT = (Button)findViewById(R.id.submitButton);
          submitBT.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                  try {
                      saveItToDB();
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
  
  
          });
      }
  
  
  
      public void saveItToDB() {
          dba.updateDiaryEntry(titleET1.getText().toString(), 1);
          dba.updateDiaryEntry(titleET2.getText().toString(), 2);
          dba.updateDiaryEntry(titleET3.getText().toString(), 3);
          dba.updateDiaryEntry(titleET4.getText().toString(), 4);
          dba.updateDiaryEntry(titleET5.getText().toString(), 5);
          dba.updateDiaryEntry(titleET6.getText().toString(), 6);
          dba.updateDiaryEntry(titleET7.getText().toString(), 7);
          dba.updateDiaryEntry(titleET8.getText().toString(), 8);
          dba.updateDiaryEntry(titleET9.getText().toString(), 9);
          dba.updateDiaryEntry(titleET10.getText().toString(), 10);
          dba.updateDiaryEntry(titleET11.getText().toString(), 11);
          dba.updateDiaryEntry(titleET12.getText().toString(), 12);
          dba.updateDiaryEntry(titleET13.getText().toString(), 13);
          dba.updateDiaryEntry(titleET14.getText().toString(), 14);
          dba.updateDiaryEntry(titleET15.getText().toString(), 15);
          dba.updateDiaryEntry(titleET16.getText().toString(), 16);
          dba.updateDiaryEntry(titleET17.getText().toString(), 17);
          dba.updateDiaryEntry(titleET18.getText().toString(), 18);
          dba.updateDiaryEntry(titleET19.getText().toString(), 19);
          dba.updateDiaryEntry(titleET20.getText().toString(), 20);
          dba.updateDiaryEntry(titleET21.getText().toString(), 21);
          dba.updateDiaryEntry(titleET22.getText().toString(), 22);
          dba.updateDiaryEntry(titleET23.getText().toString(), 23);
          dba.updateDiaryEntry(titleET24.getText().toString(), 24);
          dba.updateDiaryEntry(titleET25.getText().toString(), 25);
          dba.updateDiaryEntry(titleET26.getText().toString(), 26);
          dba.updateDiaryEntry(titleET27.getText().toString(), 27);
          dba.updateDiaryEntry(titleET28.getText().toString(), 28);
          dba.updateDiaryEntry(titleET29.getText().toString(), 29);
          dba.updateDiaryEntry(titleET30.getText().toString(), 30);
          dba.updateDiaryEntry(titleET31.getText().toString(), 31);
          dba.updateDiaryEntry(titleET32.getText().toString(), 32);
          dba.updateDiaryEntry(titleET33.getText().toString(), 33);
          dba.updateDiaryEntry(titleET34.getText().toString(), 34);
          dba.updateDiaryEntry(titleET35.getText().toString(), 35);
          dba.updateDiaryEntry(titleET36.getText().toString(), 36);
          dba.updateDiaryEntry(titleET37.getText().toString(), 37);
          dba.updateDiaryEntry(titleET38.getText().toString(), 38);
          dba.updateDiaryEntry(titleET39.getText().toString(), 39);
          dba.updateDiaryEntry(titleET40.getText().toString(), 40);
          dba.updateDiaryEntry(titleET41.getText().toString(), 41);
          dba.updateDiaryEntry(titleET42.getText().toString(), 42);
          dba.updateDiaryEntry(titleET43.getText().toString(), 43);
          dba.updateDiaryEntry(titleET44.getText().toString(), 44);
          dba.updateDiaryEntry(titleET45.getText().toString(), 45);
          dba.updateDiaryEntry(titleET46.getText().toString(), 46);
          dba.updateDiaryEntry(titleET47.getText().toString(), 47);
          dba.updateDiaryEntry(titleET48.getText().toString(), 48);
  
          dba.close();
          titleET1.setText("");
  
          titleET2.setText("");
          titleET3.setText("");
          titleET4.setText("");
          titleET5.setText("");
          titleET6.setText("");
          titleET7.setText("");
          titleET8.setText("");
          titleET9.setText("");
          titleET10.setText("");
          titleET11.setText("");
          titleET12.setText("");
          titleET13.setText("");
          titleET14.setText("");
          titleET15.setText("");
          titleET16.setText("");
          titleET17.setText("");
          titleET18.setText("");
          titleET19.setText("");
          titleET20.setText("");
          titleET21.setText("");
          titleET22.setText("");
          titleET23.setText("");
          titleET24.setText("");
          titleET25.setText("");
          titleET26.setText("");
          titleET27.setText("");
          titleET28.setText("");
          titleET29.setText("");
          titleET30.setText("");
          titleET31.setText("");
          titleET32.setText("");
          titleET33.setText("");
          titleET34.setText("");
          titleET35.setText("");
          titleET36.setText("");
          titleET37.setText("");
          titleET38.setText("");
          titleET39.setText("");
          titleET40.setText("");
          titleET41.setText("");
          titleET42.setText("");
          titleET43.setText("");
          titleET44.setText("");
          titleET45.setText("");
          titleET46.setText("");
          titleET47.setText("");
          titleET48.setText("");
  
  
          Intent i = new Intent(Diary.this, Monday.class);
          startActivity(i);
      }
      /** Called when the user clicks the Back button */
      public void visitMonday(View view) {
          Intent intent = new Intent(this, Monday.class);
          startActivity(intent);
      }
  }
  </code></pre>
  
  <p>And here is the function that I am supposed to insert into onCreate() method:</p>
  
  <pre><code>private void initializeDescription() {
      _descriptionText = (AutoCompleteTextView) findViewById(R.id.description);
      final int[] to = new int[]{android.R.id.text1};
      final String[] from = new String[]{VehicleDescriptionsTable.DESCRIPTION};
      SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
              android.R.layout.simple_dropdown_item_1line,
              null,
              from,
              to);
  
      // This will provide the labels for the choices to be displayed in the AutoCompleteTextView
      adapter.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
          @Override
          public CharSequence convertToString(Cursor cursor) {
              final int colIndex = cursor.getColumnIndexOrThrow(VehicleDescriptionsTable.DESCRIPTION);
              return cursor.getString(colIndex);
          }
      });
  
      // This will run a query to find the descriptions for a given vehicle.
      adapter.setFilterQueryProvider(new FilterQueryProvider() {
          @Override
          public Cursor runQuery(CharSequence description) {
              String vehicle = getSelectedVehicle();
              Cursor managedCursor = _helper.getDescriptionsFor(vehicle, description.toString());
              Log.d(TAG, "Query has " + managedCursor.getCount() + " rows of description for " + vehicle);
              return managedCursor;
          }
      });
  
      _descriptionText.setAdapter(adapter);
  }
  </code></pre>
  
  <p>Unfortunately when I insert this function into onCreate() method error pops up saying that there is error at tokens { and } . What am I doing wrong?</p>
  
  <p>I want the edittext to show predefined text from corresponding row in the table.</p>
  
  <p>Edit---------------------------------------------------------------------------------------</p>
  
  <p>I tried AutoCompleteTextView with CursorAdapter but I cannot see the option to pull information from rows in database. What am I missing here?</p>