Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rcc.www.loginpage;
- import android.content.Intent;
- import android.content.SharedPreferences;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.widget.TextView;
- public class Main2Activity extends AppCompatActivity
- {
- TextView Name, Password;
- SharedPreferences sharedPreference;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main2);
- /*Bundle bundle = getIntent().getExtras();
- String name = bundle.getString("Name");
- String password = String.valueOf(bundle.getInt("Password"));
- Name = findViewById(R.id.textView2);
- Password = findViewById(R.id.textView3);
- sharedPreference = getSharedPreferences("file", 0);
- String username = sharedPreference.getString("name", "No user found.");
- int pass = sharedPreference.getInt("password", 0000);
- Name.setText("Welcome ");
- Name.append(name);
- Password.setText("Password: ");
- Password.append(password);*/
- SharedPreferences prefs = getSharedPreferences("file", 0);
- String restoredText = prefs.getString("text", null);
- if (restoredText != null) {
- String name = prefs.getString("name", "No name defined");//"No name defined" is the default value.
- int idName = prefs.getInt("idName", 0); //0 is the default value.
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment