解析本地数据存储e消息"未找到查询结果"

时间:2015-05-18 17:40:35

标签: parse-platform local datastore

我正在尝试完成这个程序而且我被卡住了。这是我的第一个程序,现在它不会工作。当我添加query.fromLocalDatastore()时,我不断收到此错误;代码运行正常,直到我尝试从本地存储中获取它。这告诉我没有任何东西可供检索,我也不知道为什么。当我添加我的测试数据它工作正常,但当我尝试从另一个表拉数据时,我得到上面的错误。显然,当我添加测试数据时,服务器与本地数据存储区同步。现在不是。有人能告诉我我做错了吗?

           public class DataHolder extends Application {
                int age;

                @Override
                public void onCreate() {
                    super.onCreate();
                    Parse.enableLocalDatastore(getApplicationContext());
                    Parse.initialize(this,key, key);
                    ParseUser.enableAutomaticUser();
                    ParseACL defaultACL = new ParseACL();
                    ParseACL.setDefaultACL(defaultACL, true);
                }


      public class MainActivity extends ActionBarActivity implements Disclaimer.DisclaimerListener {  
     protected void continueToRun() {     
spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                public void onItemSelected(AdapterView<?> adapter, View v, int x, long lng) {
                    final ParseQuery<ParseObject> query = ParseQuery.getQuery("Phone_Numbers");
                    query.fromLocalDatastore();
                    if (x == 1) {
                        final Intent intent = new Intent(getBaseContext(), Protocol_Template.class);
                        query.fromLocalDatastore();
                        query.whereEqualTo("objectId", "uGANULyrdL");
                        startActivity(intent);
                    }

    }

        public class Protocol_Template extends Activity {
            DataHolder global;


            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_protocol__template);

                final TextView protocol = (TextView) findViewById(R.id.txt02);
             findViewById(R.id.btn2timesUpperLeft);

                final ParseQuery<ParseObject> query = ParseQuery.getQuery("Phone_Numbers");

                query.fromLocalDatastore();

                query.getFirstInBackground(new GetCallback<ParseObject>() {
                    public void done(ParseObject object, ParseException e) {
                        if (e == null) {
                            final String protocols = object.get("PhoneNumber").toString();

                            protocol.setText(protocols);

                        } else {
                            protocol.setText(e.getMessage());

                        }
                                               }
                                           });
            }

0 个答案:

没有答案