Counting number of users

Hallo, i really need help. How can i count the number of users using a code. I need the number of users so i can do other calculations that includes it. It’s URGENT please help

Hi Samuel,

Do you need in in Java, Obj-C, Swift, JS or REST?

Regards,
Mark

Hi Mark, In Java. My app is in android. Thanks for your fast reply. I highly appreciate.

Hi Samuel,

Here’s how you can do it today. However, please keep in mind that the getTotalObjects() method will be deprecated soon and we will provide a separate API call to get object counts:

BackendlessDataQuery query = new BackendlessDataQuery();
QueryOptions queryOptions = new QueryOptions();
queryOptions.setPageSize( 1 );
query.setQueryOptions( queryOptions );
Backendless.Data.of( BackendlessUser.class ).find( query, new AsyncCallback<BackendlessCollection<BackendlessUser>>()
{
@Override
public void handleResponse( BackendlessCollection<BackendlessUser> response )
{
int objectCount = response.getTotalObjects();
Log.i( “MY APP”, "Total number of users " + objectCount );
}

  @Override
  public void handleFault( BackendlessFault fault )
  {
    Log.e( "MY APP", "Server error " + fault.getMessage() );
  }
});

Thanks mark. Let me give it a try. Backendless ROCKS!!! :slight_smile: How are we going to be notified about the change? If you dont mind me asking

Thank you, Samuel. What change/notification are you talking about?

Here’s what you said “…However, please keep in mind that the getTotalObjects() method will be deprecated soon and we will provide a separate API call to get object counts…” when the method gets deprecated how can we be notified?

We will post about it to our blog/twitter/facebook/newsletter.