Reputation: 1757
When i call Parse
method getList("some column") i always get NullPointerException
. What should i do to avoid it?
Here is some code
ParseObject someObj = new ParseObject("Some table");
someObj.put("some column", "some text");
someObj.saveInBackground();
List<String> someList = someObj.getList("some column");
Toast.makeText(getApplicationContext(), someList.get(0), Toast.LENGHT_LONG).show()
Upvotes: 1
Views: 138
Reputation: 18507
I think that you're not getting a NPE
in List<String> someList = someObj.getList("some column");
I think that getList
is returning null
and you're getting the NPE
when you try to get the first element on this list in the follow line: someList.get(0)
.
In ParseObject
api for android:
getList
returns null if there is no such key or if the value can't be converted to a List
So since you're setting a string some text
value for some column
key in someObj.put("some column", "some text")
, you can't get this value as List
using getList("some column")
, so simply use get("some column")
instead.
Upvotes: 2