Does anyone know if it is possible to programmatically clear all of the data in a Backendless table at once? I found this article that shows how to remove individual objects one at a time but nothing on clearing the whole table at once: https://backendless.com/documentation/data/android/data_deleting_data_objects.htm
I figured out a way to do it but I don't know how efficient it is. Basically, I have a Class called LocalPhoneNum, which make up the objects that will be saved in my app table. The class contains a userID, name and phone num. I query the table to find a user with a specific email (right now there's just one user), then use the foundContacts variable in a loop to delete each object one by one.
String whereClause = "userEmailID = mark";
BackendlessDataQuery dataQuery = new BackendlessDataQuery();
dataQuery.setWhereClause( whereClause );
Backendless.Persistence.of(LocalPhoneNum.class).find(dataQuery, new AsyncCallback<BackendlessCollection<LocalPhoneNum>>(){
@Override
public void handleResponse( BackendlessCollection<LocalPhoneNum> foundContacts )
{
for (LocalPhoneNum temp : foundContacts.getData()){
Backendless.Persistence.of( LocalPhoneNum.class ).remove( temp, new AsyncCallback<Long>()
{
public void handleResponse( Long response )
{
Toast.makeText(getActivity(), "DELETED", Toast.LENGTH_LONG).show();
}
public void handleFault( BackendlessFault fault )
{
Toast.makeText(getActivity(), "NOT DELETED "+fault, Toast.LENGTH_LONG).show();
}
} );
}
Please let me know if there is a better solution or if this one is fine. Thank you!