我试图比较我的Application类和DBHelper类中的方法的答案。我在一项活动中这样做。虽然我可以使用DBHelper类的方法,但我无法访问Application类的方法
我的申请类:
public class thing extends Application {
private String thing1;
private String thing2;
private String thing3;
private String thing4;
public String getVariable() {
return thing1 + thing2 + thing3 + thing4;
}
我的活动:
public class solution extends AppCompatActivity {
protected DBHelper DB;
@Override
protected void onCreate(Bundle savedInstanceState) {
...
}
}
final Button solution = findViewById(R.id.solutionbutton);
sol.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
DBHelper db = new DBHelper(getApplicationContext());
if(db.getDODO("two").equals(thing.getVariable())){
....
}
});
}}