在Parse.com用户访问表中的自定义列返回空我 [英] Accessing a custom column in Parse.com user table returning me null
问题描述
我想找回一个名为地址新列在我分析用户在我的Android应用程序创建的。但它返回我的NullPointerException错误,并返回我什么,虽然我在桌上摆满的地址。
这链接只能说明你的自定义字段存储在用户表的方式,但我需要找回我存储在那里。
这是我的code:
I am trying to retrieve a new column called "address" I created in Parse User in my android app. But it returns me nullPointerException error and returns me nothing although I filled the address in the table.
This link only shows the way to store your custom field in the user table but I need to retrieve what I stored there.
This is my code:
ParseUser pUser = ParseUser.getCurrentUser();
userAddress.setText(pUser.getString("address").toString());
我试过的get(地址)
以及,但仍返回我什么。有什么事,我在这里丢失?
I tried get("address")
as well but still it returns me nothing. Is there something I'm missing here?
推荐答案
好吧,我发现我自己的答案。事实证明,解析本地缓存 ParseUser.getCurrentUser()
对象和原因,我无法从服务器获取数据,是因为我改变了对服务器中的数据和未更新的客户机高速缓存。
我能够通过从服务器获取ParseUser对象来解决这个问题:
Alright, I found the answer on my own. It turns out that Parse caches the ParseUser.getCurrentUser()
object locally and the reason I wasn't able to get the data from server was because I changed the data on server and the client cache wasn't updated.
I was able to fix this by fetching the ParseUser object from the server:
ParseUser.getCurrentUser().fetchInBackground();
对象从服务器中检索
再后,我能得到我的客户端上的地址栏。
and then after the object is retrieved from the server I was able to get the address field on my client.
这篇关于在Parse.com用户访问表中的自定义列返回空我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!