【问题标题】:Parse.com Android get object and relation with ParseUserParse.com Android 获取对象和与 ParseUser 的关系
【发布时间】:2015-12-28 13:48:21
【问题描述】:

我在 Android 中有这段代码:

            ParseUser user = new ParseUser();
            user.setUsername(email.getText().toString().trim());
            user.setPassword(password.getText().toString().trim());
            user.setEmail(email.getText().toString().trim());
            user.pinInBackground();
            user.saveInBackground();
            ParseObject UserProfile = new ParseObject("UserProfile");
            UserProfile.put("Name", name.getText().toString().trim());
            UserProfile.put("UserMobile", mobile.getText().toString().trim());
            UserProfile.saveInBackground();
            UserProfile.pinInBackground();

这段代码运行良好,但如何从 Parse 类 UserProfile 获取数据以及如何将 ParseUser 与 UserProfile 关联起来?

谢谢

【问题讨论】:

    标签: android parse-platform


    【解决方案1】:

    只需在您的用户表中创建一个“指针”字段。 在此之后,您可以在您的用户表中放置一个指向配置文件的指针

    user.put(userprofile) 
    

    【讨论】:

    • 如何从 UserProfile 获取数据?比如姓名、手机?
    • 我还是不明白。我如何链接它以及如何从 UserProfile 获取用户数据?
    【解决方案2】:

    您可以使用指针链接两个对象。为此,只需添加

    user.put("CurrentUser",userprofile);
    

    还在表格中创建一个“CurrentUser”指针字段。

    您可以通过以下方式访问用户配置文件数据:

    user.getParseObject("CurrentUser").fetch().get("Name");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-09
      • 1970-01-01
      • 2017-02-12
      相关资源
      最近更新 更多