I have an app which uses a login using Google+. I want the login screen to appear only for the first time, and then when the user logs out of the app. What should I do for this? I'm using this as the firstActivity for the app.
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
public class firstActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(i);
finish();
}
});
}
}
Now I do not know how to create a variable which can be assigned a value and be stored on the device, which will only be changed on logging out. How should I proceed?