Android Help for Check Like Button from mysqli server strategy


I have online music application.

My Application has 1 listview and 1 fragment player page.

player page has like button (2 state):

  • is like (red heart icon)
  • no like (white heart icon)

my method is check like from mysqli database server using by send post request to server and get json response include (0-> false or 1->true). false means no like and true means liked.

now, for every request and open player fragment this request post to server for checking. number of requests too much and my server Does not rest :\

my method Not worth it :|

Methods and Facebook apps like Instagram likes to check out what is?

Show source
| facebook   | performance   | android   | mysqli   | instagram   2016-12-30 17:12 1 Answers

Answers ( 1 )

  1. 2016-12-30 18:12

    You don't have to do that. The thing Facebook or other big social media company do is they include like state while they request JSON from the server. So you need to add JOIN logic to your sql query. Every time you request JSON data for your listView your JSON data will be something like this:

        .... //all of yours json data
        likeState : "true"

    Then you need to pass those data into intent if your using activity for display the detail from that current list item or if your using fragment you can follow this link on how to send data from activity to fragment. Check wether likeState is true then you know what else to do rather than keep request data from the server every time you open up your fragment.

◀ Go back