What mean "my counter" in Atomic Counters API documentation

Hello.I read documentation about Atomic Counters API and don’t understand what mean “my counter” argument.
I want to increment some field in some table. What i must do?

The “my counter” argument in the examples references a specific counter. This is just a name so you can identify a particular counter.

You should be able to use counters for incrementing fields in a table. The algorithm would look like this:

    Setup a counter and assign the initial value (or keep it as 0). When you need to update an object (increment a field), increment and retrieve counter value. Assign the value of the counter to the field in your object. Save the object.
Regards, Mark

Sorry, Mark. How to setup a counter? I can’t see any settings for counters in my account and can’t see any methods in sdk.

Hi Adam.
You can set this variable in your client code or run request like this (sample for REST):

curl -H application-id:YOUR-APP-ID -H secret-key:YOUR-SECRET-KEY -application-type:REST -X PUT https://api.backendless.com/v1/counters/mycounter/get/increment

and this variable(“mycounter”) would be automatically set to null.

Regards,
Kate.

Спасибо, Катя!
Thank, Mark!

Hello, Kate! Cant understand where the counters are storaged and curl doesnt work… But its works for another requestshttp://support.backendless.com/public/attachments/09816b64ecc6b7c4f2c6ece941656e1b.PNG</img>

Counters are stored on our servers. There appears to be a problem with SSL on your computer. Change the url in the curl command to use http://api.backendless.com

Hi! I don’t understand this completely… I’m trying to implement an upvoiting system to pics in my app, I think I could use this but I’m not sure… Would that be OK?

I do not quite understand is this:

  1. How do I create a counter in Android?
  2. If I created a counter for every single pic, wouldn’t that be like too many counters? And in case it’s OK to do it this way, I wouldn’t need a variable on my Picture object to save the upvotes because they would be in the counter… it’s that OK?

I’m sorry since I’m obiously quiet new at this… But I understand the rest of the API so I hope I will be able to understand this too…

Thanks!
Marcos.

Hello Marcos,

I don’t think API counters are meant to be used in this manner.
An example on how to use them would be when you are creating a sales order number: the number should be incremented automatically and only saved once the order itself has been saved to a database.