Ali Bdeir
Ali Bdeir

Reputation: 4365

How can i get a WHOLE column value from parse.com in android?

I want to have an array, and that array is going to be for a spinner. I want the value of that arraylist to be all the values stored in the column "title" in the parse class SpinnerClass. I've looked on the internet but I didn't really understand the other's code and it wa`s really confusing.

Edit: I doubt you guys understand: I have a parse class, and in that class, I have a column named POSTS. It is not a user class. And I want to get ALL the posts from all the rows. So if I have 3 rows, each with posts "red", green", "blue", I want my app to get "red" "green" "blue" from the parse database, and store it in my spinner Thanks for the help

Upvotes: 0

Views: 470

Answers (2)

nasch
nasch

Reputation: 5498

I think you can set up a ParseQueryAdapter to do that.

https://parse.com/tutorials/parse-query-adapter

Add this line to the app's Gradle to be able to import ParseQueryAdapter:

    compile 'com.parse:parseui-widget-android:0.0.1'

Also, so you can get your column:

    // "SpinnerClass" is the class your column is found in parse
    ParseQueryAdapter<ParseObject> adapter = new ParseQueryAdapter<ParseObject>
(this,"SpinnerClass");
    //And to get the column, "Title" is the name of your column
            adapter.setTextKey("Title");
    //And this is to set the spinner adapter
            spinner.setAdapter(adapter);

Upvotes: 1

Marius Waldal
Marius Waldal

Reputation: 9932

There is no way to query for columns like this. You could create a cloud code job to fetch things for you (to avoid this bloated query and work on the client), but your best bet would be to rethink your data model.

You need to plan your data model based on your queries; not by any normalization of data. So if getting all the values in this POST column is a query that you will frequently perform, you should create a data model where these values are i.e. stored in an array somewhere for easy retrieval by a simple query. You could have a Spinner object with a posts field that stores an array of those values. This field could for example be populated in an afterSave() event in cloud code.

Upvotes: 0

Related Questions