title: setting SQLite DataBase to TextView With ActionBar and AlertDialog
body: <p><a href="https://i.stack.imgur.com/8jYIs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8jYIs.png" alt="enter image description here"></a></p>
  
  <p>Here having detail (firstname, lastname, mobile, password, email id) that is stored in database.</p>
  
  <p>I set a list so that it will get my database details to <code>TextView</code>. I have done <code>DataBase</code>, <code>ActionBar</code>, <code>AlertDialogue</code>. while clicking <code>ActionBar</code> an <code>AlertDialog</code> will open. There by clicking "ok" button the details must arrange in <code>TextView</code>.</p>
  
  <p>My code is given below:</p>
  
  <pre><code>public class DatabaseHelper extends SQLiteOpenHelper {
  
  public static String dataBaseName = "Login.db";
  
  private static final int dataBaseVersion = 1;
  
  private static final String tableName = "Accounts";
  private static String Key_Id = "id";
  private static String Key_FirstName = "firstname";
  private static String Key_LastName = "lastname";
  private static String Key_Password = "password";
  private static String Key_Mobile = "mobile";
  private static String Key_Email = "email";
  
  public static String tag = "tag";
  
  private static final String createTableAccounts = "CREATE TABLE " + tableName + "( " + Key_Id + " INTEGER PRIMARY KEY AUTOINCREMENT, " + Key_FirstName + " TEXT, " + Key_LastName + " TEXT, " + Key_Password + " TEXT, " + Key_Mobile + " TEXT, " + Key_Email + " TEXT );";
  
  public DatabaseHelper(Context context) {
      super(context, dataBaseName, null, dataBaseVersion);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
  
      db.execSQL(createTableAccounts);
  
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  
      db.execSQL("DROP TABLE IF EXISTS" + createTableAccounts);
      onCreate(db);
  
  }
  
  public long addAccountDetials(AccountsModel accounts) {
      SQLiteDatabase db = this.getWritableDatabase();
  
      ContentValues values = new ContentValues();
      values.put(Key_FirstName, accounts.firstName);
      values.put(Key_LastName, accounts.lastName);
      values.put(Key_Password, accounts.passWord);
      values.put(Key_Mobile, accounts.mobile);
      values.put(Key_Email, accounts.emailId);
  
      long insert = db.insert(tableName, null, values);
      return insert;
  }
  
  public int updateEntry(AccountsModel accounts) {
      SQLiteDatabase db = this.getWritableDatabase();
  
      ContentValues values = new ContentValues();
      values.put(Key_FirstName, accounts.firstName);
      values.put(Key_LastName, accounts.lastName);
      values.put(Key_Password, accounts.passWord);
      values.put(Key_Mobile, accounts.mobile);
      values.put(Key_Email, accounts.emailId);
  
      return db.update(tableName, values, Key_Id + "=?", new String[]{String.valueOf(accounts.id)});
  }
  
  public void deleteEntry(long id) {
      SQLiteDatabase db = this.getWritableDatabase();
      db.delete(tableName, Key_Id + " = ?", new String[]{String.valueOf(id)});
  }
  
  public AccountsModel getAccounts(long id) {
      SQLiteDatabase db = this.getReadableDatabase();
  
      String selectQuery = "SELECT  * FROM " + tableName + " WHERE "
              + Key_Id + " = " + id;
      Log.d(tag, selectQuery);
  
      Cursor c = db.rawQuery(selectQuery, null);
  
      if (c != null)
          c.moveToFirst();
  
      AccountsModel accountsModel = new AccountsModel();
      accountsModel.id = c.getString(c.getColumnIndex(Key_Id));
      accountsModel.firstName = c.getString(c.getColumnIndex(Key_FirstName));
      accountsModel.lastName = c.getString(c.getColumnIndex(Key_LastName));
      accountsModel.mobile = c.getString(c.getColumnIndex(Key_Mobile));
      accountsModel.passWord = c.getString(c.getColumnIndex(Key_Password));
      accountsModel.emailId = c.getString(c.getColumnIndex(Key_Email));
  
      return accountsModel;
  }
  public List&lt;AccountsModel&gt; getAllAccountList() {
      List&lt;AccountsModel&gt; accountsModelArrayList = new ArrayList&lt;AccountsModel&gt;();
  
      String selectQuery = "SELECT  * FROM " + tableName;
      Log.d(tag, selectQuery);
  
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor c = db.rawQuery(selectQuery, null);
  
      if (c.moveToFirst()) {
          do {
  
              AccountsModel accountsModel = new AccountsModel();
              accountsModel.id = c.getString(c.getColumnIndex(Key_Id));
              accountsModel.firstName = c.getString(c.getColumnIndex(Key_FirstName));
              accountsModel.lastName = c.getString(c.getColumnIndex(Key_LastName));
              accountsModel.mobile = c.getString(c.getColumnIndex(Key_Mobile));
              accountsModel.passWord = c.getString(c.getColumnIndex(Key_Password));
              accountsModel.emailId = c.getString(c.getColumnIndex(Key_Email));
  
              accountsModelArrayList.add(accountsModel);
          } while (c.moveToNext());
      }
  
      return accountsModelArrayList;
  }}
  </code></pre>
  
  <p>MainActivity</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  EditText firstName;
  EditText lastName;
  EditText mobile;
  EditText password;
  EditText email;
  
  ListView listView;
  
  List&lt;AccountsModel&gt;list=new ArrayList&lt;AccountsModel&gt;();
  
  DatabaseHelper databaseHelper;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      databaseHelper =new DatabaseHelper(getApplicationContext());
      firstName=(EditText)findViewById(R.id.edt_firstname);
      lastName=(EditText)findViewById(R.id.edt_lastname);
      mobile=(EditText)findViewById(R.id.edt_mobile);
      password=(EditText)findViewById(R.id.edt_password);
      email=(EditText)findViewById(R.id.edt_email);
  
      listView=(ListView)findViewById(R.id.lst_view);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_add) {
          AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
          builder.setTitle("ADD DATA TO LIST");
          builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which,View v) {
  
                  if(v == findViewById(R.id.action_add)){
                      listView.setAdapter(" ");
                      AccountsModel accountsModel = new AccountsModel();
                      accountsModel.firstName = firstName.getText().toString();
                      accountsModel.lastName = lastName.getText().toString();
                      accountsModel.mobile = mobile.getText().toString();
                      accountsModel.passWord = password.getText().toString();
                      accountsModel.emailId = email.getText().toString();
  
                      databaseHelper.addAccountDetials(accountsModel);
                      list = accountsModel.getAllAccountList();
                  }
                  ArrayAdapter&lt;String&gt; arrayAdapter = new ArrayAdapter&lt;String&gt;(getApplicationContext(), android.R.layout.simple_list_item_1, value);
  
                  String value = "";
                  for (AccountsModel accountsModel : list) {
                      value = value + "id: " + accountsModel.id + ", firstName : " + accountsModel.firstName + " lastName : " + accountsModel.lastName + "mobile : " + accountsModel.mobile + " passWord : " + accountsModel.passWord + " email : " + accountsModel.emailId + "\n";
                  }
                  listView.setAdapter(value);
              }
  
          });
          builder.setNeutralButton("CANCEL", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
  
              }
          });
          AlertDialog alertDialog = builder.create();
          alertDialog.show();
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }}
  </code></pre>
  
  <p>AccountsModel</p>
  
  <pre><code>public class AccountsModel {
  
  public int id;
  public String firstname;
  public String lastname;
  public String password;
  public String mobile;
  public String email;
  
  public AccountsModel(int id,String firstname,String lastname,String password,String mobile,String email)
  {
      this.id=id;
      this.firstname=firstname;
      this.lastname=lastname;
      this.password=password;
      this.mobile=mobile;
      this.email=email;
  }
  public  AccountsModel()
  {
  
  }}
  </code></pre>
  
  <p>Please modify code according to my app so that I can understand, as I am new to android.</p>
  
  <p>error i am facing</p>
  
  <blockquote>
    <p>Error:(75, 45) error: cannot find symbol method getAllAccountList()
    Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
    Compilation failed; see the compiler error output for details.</p>
  </blockquote>