[英]Getting a NullPointerException while trying to parse XML file using DOM
[英]NullPointerException while using Parse
当我调用Parse
方法getList(“ some column”)时,我总是得到NullPointerException
。 我应该怎么做才能避免这种情况? 这是一些代码
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()
我认为您没有在List<String> someList = someObj.getList("some column");
获得NPE
List<String> someList = someObj.getList("some column");
我认为getList
返回null
,当您尝试在以下行中获取此列表中的第一个元素时,您将获得NPE
: someList.get(0)
。
如果没有这样的键或无法将值转换为List,则
getList
返回null
因此,由于您要为someObj.put("some column", "some text")
some column
键设置字符串some text
值,因此无法使用getList("some column")
将此值作为List
获得,因此只需使用get("some column")
代替。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.