Alex Smith Alex Smith - 1 year ago 56
Android Question

How to get all column from Realm's DB table?

I know that question is stupid, but I need to create Spinner using Realm and get one column for this.
All I want is get one all columt to String array to use ArrayAdapter. How can I get this column? Or maybe the better way is extend ArrayAdapter where I will get all rows from that column using a loop? Tell me, please, the better solution.

Answer Source

There are special Adapters for Realm:

Example code:

public class MyListAdapter extends RealmBaseAdapter<TimeStamp> implements ListAdapter {

    private static class ViewHolder {
        TextView timestamp;

    public MyListAdapter(OrderedRealmCollection<TimeStamp> realmResults) {

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext())
                    .inflate(android.R.layout.simple_list_item_1, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.timestamp = (TextView) convertView.findViewById(;
        } else {
            viewHolder = (ViewHolder) convertView.getTag();

        TimeStamp item = adapterData.get(position);
        return convertView;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download