extract username in home view

This commit is contained in:
2023-12-20 11:28:56 +02:00
parent fbca53d3fc
commit 5a8301b07d

View File

@@ -1,8 +1,10 @@
package com.example.myapp_1;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
@@ -42,6 +44,10 @@ public class HomeActivity extends AppCompatActivity {
return true;
}
});
TextView userGreeting = findViewById(R.id.userGreeting);
SharedPreferences currentUserThings = getSharedPreferences("userData", MODE_PRIVATE);
String user = currentUserThings.getString("username", "");
userGreeting.setText("Welcome " + user + "!");
}
}