[Solved] Why can’t i call a method within a protected method of the same class [duplicate]

You are creating local variables of button1, button2 etc inside the onCreate method. This way, the generateQuestion method is unaware of these variables and uses the class variables with the same name (not included in your code, but I imagine you have somewhere declared them probably on top of your activity class) which are not … Read more

[Solved] Why can’t i call a method within a protected method of the same class [duplicate]

Introduction When writing code in an object-oriented language, it is important to understand the concept of access modifiers. Access modifiers are used to control the visibility of class members, such as methods, variables, and constructors. One of the access modifiers is the protected modifier, which allows a class to access its own members, but not … Read more

[Solved] I get an error like this, and application closes

I think in your code you are comparing two strings using equals function like String1.equals(String2) in your case String1 is null (not initialized), and it is the root cause of this exception. For example: String string1 = getInputText(); boolean status = false; if(string1 != null) { status = string1.equals(string2); } So please check and ensure … Read more

[Solved] NullPointerException inserting into an SQLite database? [closed]

You have not initialized your variable mStockageDao. Do this in onCreate() method: StockageDAO mStockageDao = new mStockageDao(AddStockageFragment.this); And before the code: Stockage createdStockage = mStockageDao.createStockage(stockqte,datestock,seulstock,LocalStock,1); call this mStockageDao.open(); NOTE: When you are done querying your database, call mStockageDao.close(); solved NullPointerException inserting into an SQLite database? [closed]

[Solved] Android Studio: App is crashing after running it on my smartphone [duplicate]

you have to write following in onCreate after setContentView() Button btnplus = (Button)findViewById(R.id.btnplus); RatingBar ratingbar = (RatingBar)findViewById(R.id.ratingBar); like below. public class MainActivity extends AppCompatActivity { Button btnplus; RatingBar ratingbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnplus = (Button)findViewById(R.id.btnplus); ratingbar = (RatingBar)findViewById(R.id.ratingBar); } public void plusonclick() { if (ratingbar.getRating() == 1) { setContentView(R.layout.activity_plusrechnenlvl1); } … Read more

(Solved) What is a NullPointerException, and how do I fix it?

There are two overarching types of variables in Java: Primitives: variables that contain data. If you want to manipulate the data in a primitive variable you can manipulate that variable directly. By convention primitive types start with a lowercase letter. For example variables of type int or char are primitives. References: variables that contain the … Read more