title: SQLite - Displaying data from database into alert dialog cuts the message
body: <p>I'm trying to display data from SQLite database into alert dialog using string buffer but when I run the app I got the message without the data from the tables. Here are two methods I used (Users.java) : </p>
  
  <pre><code> public void viewAll() { 
   btn2.setOnClickListener(
   new OnClickListener() {
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
          Cursor Res = db.getAllData();
          if(Res.getCount() == 0) {
              showMessage("Error" , "nothing found" );
              return;
  
          } 
           buffer = new StringBuffer();
                   while(Res.moveToNext()) { emailstring = Res.getString(0);
                   passstring = Res.getString(1);
              buffer.append("password : "+ emailstring + "\n");
              buffer.append("email : "+ passstring + "\n\n");
  // when I run the app the alert dialog shows "password :" and "email :" just  
          }
       data = buffer.toString();
          showMessage("data", data);  
          } 
   }  );
  
  } 
  public void showMessage(String title,String Message)
  { 
      AlertDialog.Builder builder = new AlertDialog.Builder(Users.this);
      builder.setCancelable(true);
      builder.setTitle(title);
      builder.setMessage(Message);
      builder.show();
  }
  
    //getAllData() (in databasehelper.java) :
  public Cursor getAllData() { 
    SQLiteDatabase db = this.getWritableDatabase();
  
    Cursor Res = db.rawQuery("SELECT  * FROM " + TABLE_NAME  , null);
    return Res;
       }
  }
  </code></pre>
  
  <p>inserting to the database : </p>
  
  <pre><code> public class Users extends Activity
   {
   EditText user; 
   EditText pass;
   String email;
   String pass2;
   Button btn2;
   Button btn;
   StringBuffer buffer;
   String data;
   String emailstring;
   String passstring;
  
   DBhelper2 db;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.user);
      user = (EditText) findViewById (R.id.emailadress);
      pass = (EditText) findViewById (R.id.passkelme);
       btn = (Button)findViewById(R.id.Button1);
        btn2 = (Button)findViewById(R.id.button2);
      email = user.getText().toString();
      pass2 = pass.getText().toString();
  addData();      
  viewAll();
  
  
  } 
  public void addData() {
  btn.setOnClickListener(     new OnClickListener() {
  
  @Override
  public void onClick(View v) {
      // TODO Auto-generated method stub
  
          // TODO Auto-generated method stub
       db = new DBhelper2(getApplicationContext());
          if(CheckifEmpty(user) == false &amp;&amp; CheckifEmpty(pass) == false ) { 
              if(db.insertusers2(pass2, email) == true)
              {   Toast.makeText(getApplicationContext(), "data saved succesfully" , Toast.LENGTH_LONG).show();
  
              }
              else {  Toast.makeText(getApplicationContext(), "data saved not succesfully" , Toast.LENGTH_LONG).show();}
          }
          if(CheckifEmpty(user) == true || CheckifEmpty(pass) == true ) {
              Toast.makeText(getApplicationContext(), "error you must fill the 2 fields " , Toast.LENGTH_LONG).show();
          } 
      }
  
  });
  }
  </code></pre>
  
  <p>insert function (databasehelper) : </p>
  
  <pre><code>public boolean insertusers2( String P ,String E )
   {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentvalues = new ContentValues();
  
  contentvalues.put(COLUMN_PASSWORD, P);
  contentvalues.put(COLUMN_EMAIL, E);
  if(db != null) {db.insert("tbldata", null, contentvalues);
  return true;
  }
  return false;
  
  }
  </code></pre>