从Local Data Store加载数据时会花费太多时间,有时会引发异常

时间:2014-07-17 08:10:56

标签: android parse-platform

这是我的代码,我正在使用Parse,当我从本地数据存储加载数据时需要太多时间..以及当我打开我的应用程序时。第一次加载,但当我回去尝试打开相同的活动时,它会抛出异常。请帮帮我:(

try {
        ParseQuery<ParseObject> query=ParseQuery.getQuery("ClassName");
        List<ParseObject> objects = query.find();
        ParseObject.pinAllInBackground(objects);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        Toast.makeText(getBaseContext(), "Exception(u r offline)", Toast.LENGTH_SHORT).show();
    }



        ParseQuery<ParseObject> query1=ParseQuery.getQuery("ClassName");
        query1.fromLocalDatastore();
        query1.findInBackground(new FindCallback<ParseObject>() {

        @Override
        public void done(List<ParseObject> objects, ParseException e) {
            // TODO Auto-generated method stub
            try{
            pd.dismiss();
            for(ParseObject obj : objects)
            {
                ArraylistName.add(obj.getString("PackageName"));
                ArraylistId.add(obj.getInt("Id"));
            }

            ArrayAdapter<String> ad = new ArrayAdapter<String>(getBaseContext(),android.R.layout.simple_list_item_1,ArraylistName);
            lv.setAdapter(ad);
            }
            catch(Exception ex)
            {
                pd.dismiss();
                Toast.makeText(getBaseContext(), "Some Error occured", Toast.LENGTH_SHORT).show();

            }

0 个答案:

没有答案