Get Can't pass null for argument 'pathString' in child() error












0















I having some trouble with how to use a Button to access another activity with data from firebase. I'm just getting an error "Can't pass null for argument 'pathString' in child()". But when I try in another activity with OnItemClick on a listview item it works. Why is that?



What I'm trying to do is: I have a activity with a listview that stores and get data from firebase. What I want is, if I click on one of the items in that listview I want a new activity with buttons, and these buttons will get me to another activity with a listview that are related to the first activity (related data). So the activity with the buttons are the same activity for every listview items i click on, like just a "dummy" activity. Is this possible?



Here is the code:



lvjobbinfo works fine, but add doesn't. I want lvjobbinfo and add to do the same.



public class MainActivity extends AppCompatActivity {

EditText etinfonavn;
ListView lvjobbinfo;
TextView tvjobbnavn;
Button add;

DatabaseReference databaseJOBBINFO;

List<Main> jobbinfo;

public static final String infonavn = "infonavn";
public static final String infoid = "infoid";



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

databaseJOBBINFO = FirebaseDatabase.getInstance().getReference().child("Jobbinfo");


lvjobbinfo = (ListView)findViewById(R.id.lvjobbinfo);


lvjobbinfo.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {

Main main = jobbinfo.get(i);

Intent intent = new Intent(getApplicationContext(), Notater.class);

intent.putExtra(infoid, main.getInfoId());
intent.putExtra(infonavn, main.getInfonavn());

startActivity(intent);

return true;


}
});

tvjobbnavn = (TextView)findViewById(R.id.tvjobbnavn);
etinfonavn = (EditText) findViewById(R.id.etinfonavn) ;
add = (Button)findViewById(R.id.add);

add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent add = new Intent(MainActivity.this, Notater.class);
startActivity(add);
}
});




Intent intent = getIntent();

jobbinfo = new ArrayList<>();


String id = intent.getStringExtra(Jobbliste.jobbId);
String navn = intent.getStringExtra(Jobbliste.jobbnavn);

tvjobbnavn.setText(navn);

databaseJOBBINFO = FirebaseDatabase.getInstance().getReference("Jobbinfo").child(id);




}
@Override
protected void onStart() {
super.onStart();

databaseJOBBINFO.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
jobbinfo.clear();

for (DataSnapshot infosnapshot : dataSnapshot.getChildren()) {

final Main main = infosnapshot.getValue(Main.class);
jobbinfo.add(main);


final listMain infolistadapter = new listMain(MainActivity.this, jobbinfo);

lvjobbinfo.setAdapter(infolistadapter);

infolistadapter.notifyDataSetChanged();

}




}

@Override
public void onCancelled(DatabaseError databaseError) {




}
});









share|improve this question

























  • The error message is telling you that something is wrong with your code at runtime. Please edit the question to share that code.

    – Doug Stevenson
    Nov 21 '18 at 20:16






  • 4





    The error indicates that you're passing null into a call to child. The only place where I see that in the code you shared is child(id), so it looks like id is null there. Run the code in a debugger and put a breakpoint on that line to see why that is.

    – Frank van Puffelen
    Nov 22 '18 at 1:05











  • As @FrankvanPuffelen said about your id being null. Did you check it? Could you solve your problem?

    – PradyumanDixit
    Nov 22 '18 at 3:25











  • Hi, thank you for the response guys, I'm gonna check it out later today.

    – Alexander
    Nov 22 '18 at 8:38











  • I tried debugging my app, but to be honest, I didn't understand so much of it. So can you help me with this? Why is it working with onItemclicklistener and not setonclicklistener?

    – Alexander
    Nov 22 '18 at 15:40
















0















I having some trouble with how to use a Button to access another activity with data from firebase. I'm just getting an error "Can't pass null for argument 'pathString' in child()". But when I try in another activity with OnItemClick on a listview item it works. Why is that?



What I'm trying to do is: I have a activity with a listview that stores and get data from firebase. What I want is, if I click on one of the items in that listview I want a new activity with buttons, and these buttons will get me to another activity with a listview that are related to the first activity (related data). So the activity with the buttons are the same activity for every listview items i click on, like just a "dummy" activity. Is this possible?



Here is the code:



lvjobbinfo works fine, but add doesn't. I want lvjobbinfo and add to do the same.



public class MainActivity extends AppCompatActivity {

EditText etinfonavn;
ListView lvjobbinfo;
TextView tvjobbnavn;
Button add;

DatabaseReference databaseJOBBINFO;

List<Main> jobbinfo;

public static final String infonavn = "infonavn";
public static final String infoid = "infoid";



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

databaseJOBBINFO = FirebaseDatabase.getInstance().getReference().child("Jobbinfo");


lvjobbinfo = (ListView)findViewById(R.id.lvjobbinfo);


lvjobbinfo.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {

Main main = jobbinfo.get(i);

Intent intent = new Intent(getApplicationContext(), Notater.class);

intent.putExtra(infoid, main.getInfoId());
intent.putExtra(infonavn, main.getInfonavn());

startActivity(intent);

return true;


}
});

tvjobbnavn = (TextView)findViewById(R.id.tvjobbnavn);
etinfonavn = (EditText) findViewById(R.id.etinfonavn) ;
add = (Button)findViewById(R.id.add);

add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent add = new Intent(MainActivity.this, Notater.class);
startActivity(add);
}
});




Intent intent = getIntent();

jobbinfo = new ArrayList<>();


String id = intent.getStringExtra(Jobbliste.jobbId);
String navn = intent.getStringExtra(Jobbliste.jobbnavn);

tvjobbnavn.setText(navn);

databaseJOBBINFO = FirebaseDatabase.getInstance().getReference("Jobbinfo").child(id);




}
@Override
protected void onStart() {
super.onStart();

databaseJOBBINFO.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
jobbinfo.clear();

for (DataSnapshot infosnapshot : dataSnapshot.getChildren()) {

final Main main = infosnapshot.getValue(Main.class);
jobbinfo.add(main);


final listMain infolistadapter = new listMain(MainActivity.this, jobbinfo);

lvjobbinfo.setAdapter(infolistadapter);

infolistadapter.notifyDataSetChanged();

}




}

@Override
public void onCancelled(DatabaseError databaseError) {




}
});









share|improve this question

























  • The error message is telling you that something is wrong with your code at runtime. Please edit the question to share that code.

    – Doug Stevenson
    Nov 21 '18 at 20:16






  • 4





    The error indicates that you're passing null into a call to child. The only place where I see that in the code you shared is child(id), so it looks like id is null there. Run the code in a debugger and put a breakpoint on that line to see why that is.

    – Frank van Puffelen
    Nov 22 '18 at 1:05











  • As @FrankvanPuffelen said about your id being null. Did you check it? Could you solve your problem?

    – PradyumanDixit
    Nov 22 '18 at 3:25











  • Hi, thank you for the response guys, I'm gonna check it out later today.

    – Alexander
    Nov 22 '18 at 8:38











  • I tried debugging my app, but to be honest, I didn't understand so much of it. So can you help me with this? Why is it working with onItemclicklistener and not setonclicklistener?

    – Alexander
    Nov 22 '18 at 15:40














0












0








0








I having some trouble with how to use a Button to access another activity with data from firebase. I'm just getting an error "Can't pass null for argument 'pathString' in child()". But when I try in another activity with OnItemClick on a listview item it works. Why is that?



What I'm trying to do is: I have a activity with a listview that stores and get data from firebase. What I want is, if I click on one of the items in that listview I want a new activity with buttons, and these buttons will get me to another activity with a listview that are related to the first activity (related data). So the activity with the buttons are the same activity for every listview items i click on, like just a "dummy" activity. Is this possible?



Here is the code:



lvjobbinfo works fine, but add doesn't. I want lvjobbinfo and add to do the same.



public class MainActivity extends AppCompatActivity {

EditText etinfonavn;
ListView lvjobbinfo;
TextView tvjobbnavn;
Button add;

DatabaseReference databaseJOBBINFO;

List<Main> jobbinfo;

public static final String infonavn = "infonavn";
public static final String infoid = "infoid";



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

databaseJOBBINFO = FirebaseDatabase.getInstance().getReference().child("Jobbinfo");


lvjobbinfo = (ListView)findViewById(R.id.lvjobbinfo);


lvjobbinfo.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {

Main main = jobbinfo.get(i);

Intent intent = new Intent(getApplicationContext(), Notater.class);

intent.putExtra(infoid, main.getInfoId());
intent.putExtra(infonavn, main.getInfonavn());

startActivity(intent);

return true;


}
});

tvjobbnavn = (TextView)findViewById(R.id.tvjobbnavn);
etinfonavn = (EditText) findViewById(R.id.etinfonavn) ;
add = (Button)findViewById(R.id.add);

add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent add = new Intent(MainActivity.this, Notater.class);
startActivity(add);
}
});




Intent intent = getIntent();

jobbinfo = new ArrayList<>();


String id = intent.getStringExtra(Jobbliste.jobbId);
String navn = intent.getStringExtra(Jobbliste.jobbnavn);

tvjobbnavn.setText(navn);

databaseJOBBINFO = FirebaseDatabase.getInstance().getReference("Jobbinfo").child(id);




}
@Override
protected void onStart() {
super.onStart();

databaseJOBBINFO.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
jobbinfo.clear();

for (DataSnapshot infosnapshot : dataSnapshot.getChildren()) {

final Main main = infosnapshot.getValue(Main.class);
jobbinfo.add(main);


final listMain infolistadapter = new listMain(MainActivity.this, jobbinfo);

lvjobbinfo.setAdapter(infolistadapter);

infolistadapter.notifyDataSetChanged();

}




}

@Override
public void onCancelled(DatabaseError databaseError) {




}
});









share|improve this question
















I having some trouble with how to use a Button to access another activity with data from firebase. I'm just getting an error "Can't pass null for argument 'pathString' in child()". But when I try in another activity with OnItemClick on a listview item it works. Why is that?



What I'm trying to do is: I have a activity with a listview that stores and get data from firebase. What I want is, if I click on one of the items in that listview I want a new activity with buttons, and these buttons will get me to another activity with a listview that are related to the first activity (related data). So the activity with the buttons are the same activity for every listview items i click on, like just a "dummy" activity. Is this possible?



Here is the code:



lvjobbinfo works fine, but add doesn't. I want lvjobbinfo and add to do the same.



public class MainActivity extends AppCompatActivity {

EditText etinfonavn;
ListView lvjobbinfo;
TextView tvjobbnavn;
Button add;

DatabaseReference databaseJOBBINFO;

List<Main> jobbinfo;

public static final String infonavn = "infonavn";
public static final String infoid = "infoid";



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

databaseJOBBINFO = FirebaseDatabase.getInstance().getReference().child("Jobbinfo");


lvjobbinfo = (ListView)findViewById(R.id.lvjobbinfo);


lvjobbinfo.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {

Main main = jobbinfo.get(i);

Intent intent = new Intent(getApplicationContext(), Notater.class);

intent.putExtra(infoid, main.getInfoId());
intent.putExtra(infonavn, main.getInfonavn());

startActivity(intent);

return true;


}
});

tvjobbnavn = (TextView)findViewById(R.id.tvjobbnavn);
etinfonavn = (EditText) findViewById(R.id.etinfonavn) ;
add = (Button)findViewById(R.id.add);

add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent add = new Intent(MainActivity.this, Notater.class);
startActivity(add);
}
});




Intent intent = getIntent();

jobbinfo = new ArrayList<>();


String id = intent.getStringExtra(Jobbliste.jobbId);
String navn = intent.getStringExtra(Jobbliste.jobbnavn);

tvjobbnavn.setText(navn);

databaseJOBBINFO = FirebaseDatabase.getInstance().getReference("Jobbinfo").child(id);




}
@Override
protected void onStart() {
super.onStart();

databaseJOBBINFO.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
jobbinfo.clear();

for (DataSnapshot infosnapshot : dataSnapshot.getChildren()) {

final Main main = infosnapshot.getValue(Main.class);
jobbinfo.add(main);


final listMain infolistadapter = new listMain(MainActivity.this, jobbinfo);

lvjobbinfo.setAdapter(infolistadapter);

infolistadapter.notifyDataSetChanged();

}




}

@Override
public void onCancelled(DatabaseError databaseError) {




}
});






android firebase firebase-realtime-database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 1:03









Frank van Puffelen

243k29387414




243k29387414










asked Nov 21 '18 at 19:55









AlexanderAlexander

247




247













  • The error message is telling you that something is wrong with your code at runtime. Please edit the question to share that code.

    – Doug Stevenson
    Nov 21 '18 at 20:16






  • 4





    The error indicates that you're passing null into a call to child. The only place where I see that in the code you shared is child(id), so it looks like id is null there. Run the code in a debugger and put a breakpoint on that line to see why that is.

    – Frank van Puffelen
    Nov 22 '18 at 1:05











  • As @FrankvanPuffelen said about your id being null. Did you check it? Could you solve your problem?

    – PradyumanDixit
    Nov 22 '18 at 3:25











  • Hi, thank you for the response guys, I'm gonna check it out later today.

    – Alexander
    Nov 22 '18 at 8:38











  • I tried debugging my app, but to be honest, I didn't understand so much of it. So can you help me with this? Why is it working with onItemclicklistener and not setonclicklistener?

    – Alexander
    Nov 22 '18 at 15:40



















  • The error message is telling you that something is wrong with your code at runtime. Please edit the question to share that code.

    – Doug Stevenson
    Nov 21 '18 at 20:16






  • 4





    The error indicates that you're passing null into a call to child. The only place where I see that in the code you shared is child(id), so it looks like id is null there. Run the code in a debugger and put a breakpoint on that line to see why that is.

    – Frank van Puffelen
    Nov 22 '18 at 1:05











  • As @FrankvanPuffelen said about your id being null. Did you check it? Could you solve your problem?

    – PradyumanDixit
    Nov 22 '18 at 3:25











  • Hi, thank you for the response guys, I'm gonna check it out later today.

    – Alexander
    Nov 22 '18 at 8:38











  • I tried debugging my app, but to be honest, I didn't understand so much of it. So can you help me with this? Why is it working with onItemclicklistener and not setonclicklistener?

    – Alexander
    Nov 22 '18 at 15:40

















The error message is telling you that something is wrong with your code at runtime. Please edit the question to share that code.

– Doug Stevenson
Nov 21 '18 at 20:16





The error message is telling you that something is wrong with your code at runtime. Please edit the question to share that code.

– Doug Stevenson
Nov 21 '18 at 20:16




4




4





The error indicates that you're passing null into a call to child. The only place where I see that in the code you shared is child(id), so it looks like id is null there. Run the code in a debugger and put a breakpoint on that line to see why that is.

– Frank van Puffelen
Nov 22 '18 at 1:05





The error indicates that you're passing null into a call to child. The only place where I see that in the code you shared is child(id), so it looks like id is null there. Run the code in a debugger and put a breakpoint on that line to see why that is.

– Frank van Puffelen
Nov 22 '18 at 1:05













As @FrankvanPuffelen said about your id being null. Did you check it? Could you solve your problem?

– PradyumanDixit
Nov 22 '18 at 3:25





As @FrankvanPuffelen said about your id being null. Did you check it? Could you solve your problem?

– PradyumanDixit
Nov 22 '18 at 3:25













Hi, thank you for the response guys, I'm gonna check it out later today.

– Alexander
Nov 22 '18 at 8:38





Hi, thank you for the response guys, I'm gonna check it out later today.

– Alexander
Nov 22 '18 at 8:38













I tried debugging my app, but to be honest, I didn't understand so much of it. So can you help me with this? Why is it working with onItemclicklistener and not setonclicklistener?

– Alexander
Nov 22 '18 at 15:40





I tried debugging my app, but to be honest, I didn't understand so much of it. So can you help me with this? Why is it working with onItemclicklistener and not setonclicklistener?

– Alexander
Nov 22 '18 at 15:40












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419617%2fget-cant-pass-null-for-argument-pathstring-in-child-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419617%2fget-cant-pass-null-for-argument-pathstring-in-child-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?