getsadzeg getsadzeg - 1 month ago 4
Android Question

cannot add column with 'put' method in Parse database

I'm developing real-time messenger application with Parse and want to display all of users in ListView. So I also want to reference if user is online or offline, I tried 'put' method to add column named "online" and put information about it. When it went wrong, I added that column myself, but it still did not work. Here it's what I tried in UserList class at all:

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseUser;

import java.util.ArrayList;
import java.util.List;

public class UserList extends AppCompatActivity {
public static ArrayList<ParseUser> userList;
public static String TAG = "UserList";
public static ParseUser user = new ParseUser();
protected void onCreate(Bundle savedInstanceState) {

protected void onDestroy() {
protected void onResume() {
private void updateUserStatus(boolean isOnline) {
user.put("online", isOnline);
//System.out.println("getBoolean's result : " + user.getBoolean("online"));
private void loadUserList() {
ParseUser.getQuery().whereNotEqualTo("username", user.getUsername()).findInBackground(new FindCallback<ParseUser>() {
public void done(List<ParseUser> objects, ParseException e) {
if (objects != null) {
if (objects.size() == 0) System.out.println("No user found");
userList = new ArrayList<>(objects);
ListView list = (ListView) findViewById(;
list.setAdapter(new UserAdapter(UserList.this));
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
startActivity(new Intent(UserList.this, MainActivity.class));
else {
System.out.println("exception detected while loading user list");

UserAdapter class:

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.parse.ParseUser;

public class UserAdapter extends BaseAdapter {
public static String TAG = "UserAdapter";
public TextView labelname;
LayoutInflater layoutInflater;

public UserAdapter(Context context){
layoutInflater = LayoutInflater.from(context);

public int getCount() {
return UserList.userList.size();
public ParseUser getItem(int index) {
return UserList.userList.get(index);
public long getItemId(int index) {
return index;
public View getView(int pos, View v, ViewGroup group) {
ParseUser c = getItem(pos);
if (v == null) {
v = layoutInflater.inflate(R.layout.chat_item, null);
labelname = (TextView) v;
labelname.setCompoundDrawablesWithIntrinsicBounds(c.getBoolean("online") ? R.drawable.ic_online
: R.drawable.ic_offline, 0, R.drawable.arrow, 0);

return v;

I tried saveInBackground with SaveCallback, but it throws exception named:

Caused by: java.lang.IllegalArgumentException: Cannot save a ParseUser until it has been signed up. Call signUp first

But I'm puzzled more than I was 1 hour ago. I authorize my user in another class and it seems not to be problem.


This was open bug of Parse. might be possible that not solved yet. look at this and this too.

instead of saveEventually() use saveInBackground()


you can't do like that

ParseUser user = new ParseUser();

if you want logged user than get like this

ParseUser user = ParseUser.getCurrentUser();

and before getting logged user you must do sign up