title: How to view the queried data in listview in realm database?
body: <p>I am new to realm database,I am facing the issue in the realm database querying the data from the database. The queried data from the database it looks like the below image <a href="https://i.stack.imgur.com/mAfOo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mAfOo.png" alt="enter image description here"></a></p>
  
  <p>I need to view the queried data in one by one in the listview.</p>
  
  <p>The code for  add the data into the realm database.</p>
  
  <pre><code>  public class MainActivity extends AppCompatActivity {
  
      private Realm mRealm;
      EditText editText;
      Button btn,btnNext;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          editText = (EditText)findViewById(R.id.editText);
          btn = (Button)findViewById(R.id.button);
          btnNext = (Button)findViewById(R.id.button2);
          Realm.init(getApplicationContext());
          mRealm = Realm.getDefaultInstance();
          btn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  String newNames = editText.getText().toString();
                  mRealm.beginTransaction();
                  MyNames names = mRealm.createObject(MyNames.class);
                  names.setName(newNames);
                  mRealm.commitTransaction();
                  editText.setText("");
              }
          });
          btnNext.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  Intent intent  = new Intent(MainActivity.this,Main2Activity.class);
                  startActivity(intent);
              }
          });
  
  
  
      }
  
  }
  </code></pre>
  
  <p>The code for querying the data from the database.</p>
  
  <pre><code> public class Main2Activity extends AppCompatActivity {
  
      ListView listview;
      private Realm mRealm;
      Button next;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main2);
          listview = (ListView)findViewById(R.id.list);
          next = (Button)findViewById(R.id.button2);
  
          listdata();
          listAdapter();
      }
  
      public List&lt;RealmResults&lt;MyNames&gt;&gt; listdata()
      {
          List&lt;RealmResults&lt;MyNames&gt;&gt; names = new ArrayList&lt;&gt;();
          mRealm = Realm.getDefaultInstance();
          RealmQuery&lt;MyNames&gt; data = mRealm.where(MyNames.class);
          RealmResults&lt;MyNames&gt; newData = data.findAll();
          names.add(newData);
          return  names;
      }
  
      public void listAdapter()
      {
          List&lt;RealmResults&lt;MyNames&gt;&gt; newData = this.listdata();
          ArrayAdapter adapter = new ArrayAdapter(this,R.layout.list_simple,R.id.textname,newData);
          listview.setAdapter(adapter);
      }
  </code></pre>
  
  <p>public class MyNames extends RealmObject {</p>
  
  <pre><code>        String name;
          public String getName() {
              return name;
          }
  
          public void setName(String name) {
              this.name = name;
          }
      }
  </code></pre>
  
  <p>Please help how to view the queried data from the database in listview one by one .</p>