How can I save the data coming from parse.com in the device memory?

1

I'm trying to do something simple, but for me a bit complicated, I'm trying to save the data coming from parse.com on the device, because when it has internet connection it works, but when it does not have , the device does not save the data in memory, so the data only appears when it has a network.

I would like the data to be saved and whenever I recognized the internet the data was synchronized, updated.

I'm trying this:

public class Pizzarias extends ActionBarActivity {
    // Declare Variables
    Boolean bColorStatus = true;
    TextView status;
    ListView listview;
    List<ParseObject> ob;

    ProgressDialog mProgressDialog;
    ListViewAdapterPizzarias adapter;
    private List<WorldPopulation> worldpopulationlist = null;

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

        new RemoteDataTask().execute();

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_pizzarias, menu);

        //Os metodos abaixo são para mostrar o icone do aplicativo na action bar
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setLogo(R.drawable.ic_launcher);
        getSupportActionBar().setDisplayUseLogoEnabled(true);

        return true;
    }


    //RemoteDataTask AsyncTask
    private class RemoteDataTask extends AsyncTask<Void, Void, Void> {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            // Create a progressdialog
            mProgressDialog = new ProgressDialog(Pizzarias.this);
            // Set progressdialog title
            mProgressDialog.setTitle("Carregando Pizzarias");
            // Set progressdialog message
            mProgressDialog.setMessage("Aguarde...");
            mProgressDialog.setIndeterminate(false);
            // Show progressdialog
            mProgressDialog.show();
        }

        @Override
        protected Void doInBackground(Void... params) {
            // Create the array
            worldpopulationlist = new ArrayList<WorldPopulation>();


            try {

                String objectId = "GFiBnjCE4v";
                ParseObject feed = ParseQuery.get(objectId);
                feed.fetch();
                feed.put("fechado", true);
                feed.saveEventually();


                ParseQuery<ParseObject> query = ParseQuery.get("GerenciarPizzariasPatos")
                        .fromLocalDatastore()
                        .whereEquals("fechado", true)
                        .findInBackground(new FindCallback<ParseObject>() {
                            public void done(List<ParseObject> objects, ParseException e) {
                                // "feed" ParseObject will be returned in the list of results
                            }
                        });

                // Locate the column named "ranknum" in Parse.com and order list
                // by ascending,

                query.orderByAscending("nome");

                ob = query.find();
                for (ParseObject country : ob) {
                    WorldPopulation map = new WorldPopulation();
                    map.setNome((String) country.get("nome"));
                    map.setEndereco((String) country.get("endereco"));
                    map.setTelefone((String) country.get("telefone"));
                    map.setStatus((String) country.get("status"));
                    worldpopulationlist.add(map);

                }
            } catch (ParseException e) {
                Log.e("Error", e.getMessage());
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            // Locate the listview in listview_main.xml
            listview = (ListView) findViewById(R.id.listviewpizzarias);
            // Pass the results into ListViewAdapter.java
            adapter = new ListViewAdapterPizzarias(Pizzarias.this,
                    worldpopulationlist);
            // Binds the Adapter to the ListView
            listview.setAdapter(adapter);
            // Close the progressdialog
            mProgressDialog.dismiss();

        }
    }
}

These two lines of the code are giving error, it appears below the get a red wavy line indicating the error.

ParseObject feed = ParseQuery.get(objectId);
ParseQuery<ParseObject> query = ParseQuery.get("GerenciarPizzariasPatos")

Errors:

  

Error: (100, 46) error: non-static method get (String) can not be referenced from a static context   where is a type-variable:   T extends ParseObject declared in class ParseQuery

     

Error: (106, 59) error: non-static method get (String) can not be referenced from a static context   where is a type-variable:   T extends ParseObject declared in class ParseQuery

     

Error: (107, 25) error: can not find symbol method fromLocalDatastore ()

    
asked by anonymous 07.05.2015 / 21:10

0 answers