I was wondering if anyone could point me in the right direction with this. I have an SQL Lite database set up that allows the user to add their account details. It also allows to edit the account details when returning to the application.
I really want the application to identify whether the user has previously added an account or is a new user. If they are a new user it will display a register button. If it is a returning user it will forward them onto the main menu activity.
I will attach some code as an example.
Any help would be greatly appreciated!
Register.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class Register extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
}
public void btnCreate(View view) {
SQLHelper sqlHelper = new SQLHelper(this);
EditText addName = (EditText) findViewById(R.id.nameText);
EditText edtEmail = (EditText) findViewById(R.id.nameEmail);
EditText edtNumber = (EditText) findViewById(R.id.editNumber);
EditText edtAge = (EditText) findViewById(R.id.editAge);
EditText edtNurse = (EditText) findViewById(R.id.editNurse);
sqlHelper.insert(addName.getText().toString(), edtEmail.getText().toString(), Integer.parseInt(edtNumber.getText().toString()), Integer.parseInt(edtAge.getText().toString()), edtNurse.getText().toString());
Toast.makeText(this, "Account Has Been Created", Toast.LENGTH_SHORT).show();
startActivity(new Intent(Register.this, MainMenu.class));
}
}
Welcome.java:
package my.example.com.mymedicare;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class Welcome extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
};
public void btnRegister(View view) {
startActivity(new Intent(Welcome.this, Register.class));
}
public void btnContinue(View view) {
startActivity(new Intent(Welcome.this, MainMenu.class));
}
}
Aucun commentaire:
Enregistrer un commentaire