title: I want to show the column items from an existing sqlite database into an autocompletetextview using AsyncTask
body: <p>This is my <code>getall()</code> method which is in <code>DataBaseHelper</code> Class</p>
  
  <pre><code>public ArrayList&lt;String&gt; getAll(){
          ArrayList&lt;String&gt; listUsers = new ArrayList&lt;String&gt;();
          SQLiteDatabase db = this.getWritableDatabase();
          Cursor c;
  
          try {
              c = db.rawQuery("SELECT * FROM bank"  , null);
              if(c == null) return null;
  
              String name;
              c.moveToFirst();
              do {
                  name = c.getString(1);
                  listUsers.add(name);
              } while (c.moveToNext());
              c.close();
          } catch (Exception e) {
              Log.e("blushmaq", e.getMessage());
          }
  
          db.close();
  
          return listUsers;
      }
  </code></pre>
  
  <p>This is my other class where I want to populate the records from the <code>getall()</code> method which is in <code>DataBaseHelper</code></p>
  
  <pre><code>public class BankInfo extends ActionBarActivity {
  
  
      private Toolbar toolbar;
      Button searchButton;
      DataBaseHelper myDbHelper = new DataBaseHelper(this);
      TextView sample;
      AutoCompleteTextView t1;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_bank_info);
  
          sample = (TextView) findViewById(R.id.sampleTextView);
          searchButton = (Button) findViewById(R.id.searchButton);
          searchButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  new DBOperations().execute();
              }
          });
  
          toolbar = (Toolbar) findViewById(R.id.app_bar);
          setSupportActionBar(toolbar);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
          DBOperations.execute(true);
          try {
              myDbHelper.createDataBase();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  
      private class DBOperations extends AsyncTask&lt;String, Integer, String&gt; {
          @Override
          protected String doInBackground(String... params) {
  
              return params[0];
          }
  
          @Override
          protected void onPostExecute(String s) {
  
              ArrayList&lt;String&gt; brands = myDbHelper.getAll();
              t1 = (AutoCompleteTextView) findViewById(R.id.bank_name);
              if(brands != null){
                  ArrayAdapter&lt;String&gt; adapter=new ArrayAdapter&lt;String&gt;(BankInfo.this,android.R.layout.simple_dropdown_item_1line,brands);
                  t1.setThreshold(1);
                  t1.setAdapter(adapter);
              }
              sample.setText(s);
              myDbHelper.close();
          }
      }
  </code></pre>
  
  <p>I'm getting the error  <code>ArrayIndexOutofBoundException Length=0 Index=0</code></p>