Tariq Ziad Tariq Ziad - 1 year ago 82
Android Question

Methods in main activity are showing never used arror

These two methods

methods are not being used in this my main activity file. I could find the reason, I don't know where do I have to call them. I am using Android Studio.

public class MainActivity extends AppCompatActivity {

EditText userName, password;

DatabaseAdapter databaseHelper;

protected void onCreate(Bundle savedInstanceState) {

userName = (EditText) findViewById(R.id.editTextUser);
password = (EditText) findViewById(R.id.editTextPass);
databaseHelper = new DatabaseAdapter(this);

public void addUser(View view) {

String user = userName.getText().toString();
String pass = password.getText().toString();

long id = databaseHelper.insertData(user, pass);
if (id < 0) {
Message.message(this, "Unsuccessful");
} else {
Message.message(this, "Successful");

public void viewDetails(View view) {
String data = databaseHelper.getAllData();
Message.message(this, data);

Answer Source

After watching this code you are only declaring a function and give the definition of the function you are not using it or calling it .. any where that's why android studio show you not using this method's... You can call this method like addUser(); or viewDetails();

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download