I am trying to query all the parse.com users registered in my app. I followed the guide and wrote this query
try{
name=Name.getText().toString();
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.whereMatches("username", name);
query.findInBackground(new FindCallback<ParseUser>() {
public void done(List<ParseUser> objects, ParseException e) {
if (e == null) {
if (!objects.isEmpty()) {
show.setText(String.valueOf(objects.size()));
for (ParseUser singleobject : objects) {
mail[i] = singleobject.get("email").toString();
uname[i] = singleobject.get("username").toString();
i++;
}
} else {
show.setText("No Tuples");
}
} else {
Toast.makeText(getApplicationContext(), "Query Not Successful", Toast.LENGTH_LONG).show();
}
}
});
}catch (NullPointerException x){
Toast.makeText(getApplicationContext(), "Null Pointer Exception", Toast.LENGTH_LONG);
}}
This query works well when the input retrieves a single tuple but when I give an input that retrieves multiple tuples it is throwing a NULL POINTER EXCEPTION like this
Process: com.example.nirmal.sportsparse, PID: 15097
java.lang.NullPointerException
at com.example.nirmal.sportsparse.search_players$2.done(search_players.java:108)
at com.example.nirmal.sportsparse.search_players$2.done(search_players.java:99)
at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:115)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
The error code says that there is a NULL pointer in findInBackground() and
inside the for loop. I am sure that the input I gave must retrieve atleast 2 tuples as a result.
Sometimes it also throws this error and I have no idea what this means
libcore.io.ErrnoException: close failed: EBADF (Bad file number)
at libcore.io.Posix.close(Native Method)
at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:220)
at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879)
at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242)
at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:700)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
The array are declared like this
String name,mail[]=new String[100],uname[]=new String[100];
Can anyone tell me where I am going wrong??