'How do I save and retrieve images from the Imagebutton using the sharedpreferences in Android?

If you press the heart, which is the current image button, the content is stored in the DB, and if you press the heart again, the content is deleted in the DB. What I want is that when I press the heart to store the content(name=1, content=2 ...) in the DB, the heart in the sky turns into a red heart, and when I close the app, this state is saved. Similarly, when you press the red heart, the red heart turns into an empty heart, and when you close the application, this state is saved.

The following code is the code when you click the heart, which is the imagebutton. This code was written on the adapter and a heart button appears in each listview.

ImageButton btn = (ImageButton) view.findViewById(R.id.heartbutton);
        ViewHolder finalHolder = holder;
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                InsertData task = new InsertData();
                task.execute("http://" + IP_ADDRESS + "/heart.php", finalHolder.textview_info_name.getText().toString(),finalHolder.textview_info_content.getText().toString());
            }
        });
        return view;

The following image is the result avd screen. enter image description here



Solution 1:[1]

The problem with Rubys optional ()s in method calls is that it allows for unclear/ambiguous statements when passing the output of methods as parameters to other methods. In your

expect(page).to have_content 'Primary Text', wait: 10

the wait: 10 is actually being passed as the second argument to ‘to’ rather than have_content so it's being interpreted as

expect(page).to(have_content('Primary Text'), wait: 10)

To get your desired behavior you need to do

expect(page).to have_content('Primary Text', wait: 10)

One benefit of using something like rubocop is that it will flag situations like this for you

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1