I have a Database that uses a string to get information from the data base. when I use something like:
public String getString(String string){
string = "information";
return string;
}
This gets infromation But as soon as I change it to pull from a text view:
public String getString(String string){
string = textview.getText().toString();
return string;
}
I get a NullPointerException error.
also I have tried to make an intent and pull from the intent:
public String getString(String string){
string = getIntent().getExtras().getString("key");
return string;
}
and
public String getString(String string){
string = getIntent().getStringExtras("key");
return string;
}
And both ways give me NullPointerExceptions on getExtras() and getStringExtra() What am I doing wrong
For this, you might want to retrieve the textview’s content first before passing in the value “string” into this method. Eventually the method would look like this.
And this, you missed out a closing bracket.