Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.saigopinarimeti.helloworld;
- import android.content.SharedPreferences;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.widget.TextView;
- public class HomeActivity extends AppCompatActivity {
- TextView textView;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_home);
- textView = findViewById(R.id.text);
- SharedPreferences sharedPreferences = getSharedPreferences("user",MODE_PRIVATE);
- if (sharedPreferences!=null){
- String username = sharedPreferences.getString("username","sai");
- textView.setText("Logged in as "+username);
- }
- }
- }
Add Comment
Please, Sign In to add comment