Создай профиль пользователя после регистрации или входа , данные профиля должны быть сохранены после перезагрузки приложения и изменяться если был зарегистрирован или вошел другой пользователь напиши весь необходимый код , чтобы профиль функционировал включая xml :package com.example.myapp_2.Data.register;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.example.myapp_2.R;
import com.example.myapp_2.UI.view.fragments.FirstFragment;

public class LoginFragment extends Fragment {

private EditText editTextEmail, editTextPassword;
private Button buttonLogin;

private UserDAO userDAO;

public LoginFragment() {

}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

userDAO = new UserDAO(getActivity());
userDAO.open();
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.login, container, false);

getActivity().findViewById(R.id.bottomNavigationView).setVisibility(View.GONE);
editTextEmail = view.findViewById(R.id.editTextEmail);
editTextPassword = view.findViewById(R.id.editTextPassword);
buttonLogin = view.findViewById(R.id.buttonLogin);

buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = editTextEmail.getText().toString();
String password = editTextPassword.getText().toString();

if (userDAO.login(email, password)) {
Toast.makeText(getActivity(), “Login successful”, Toast.LENGTH_SHORT).show();

// переход на другой фрагмент
FragmentTransaction transaction = requireActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.nav_container, new FirstFragment());
transaction.addToBackStack(null);
transaction.commit();
} else {
Toast.makeText(getActivity(), “Invalid email or password”, Toast.LENGTH_SHORT).show();
}
}
});
Button buttonReturn = view.findViewById(R.id.buttonReturn);

buttonReturn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentTransaction transaction = requireActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.nav_container, new RegistrationFragment());
transaction.addToBackStack(null);
transaction.commit();
}
});

return view;
}

@Override
public void onDestroy() {
super.onDestroy();
userDAO.close();
}
}
package com.example.myapp_2.Data.register;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.example.myapp_2.R;
import com.example.myapp_2.UI.view.fragments.FirstFragment;

import java.util.List;

public class RegistrationFragment extends Fragment {

private EditText editTextName, editTextEmail, editTextPassword;
private Button buttonRegister_1;

private UserDAO userDAO;

public RegistrationFragment() {

}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

userDAO = new UserDAO(getActivity());
userDAO.open();
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.refister, container, false);

getActivity().findViewById(R.id.bottomNavigationView).setVisibility(View.GONE);
editTextName = view.findViewById(R.id.editTextName);
editTextEmail = view.findViewById(R.id.editTextEmail);
editTextPassword = view.findViewById(R.id.editTextPassword);
buttonRegister_1 = view.findViewById(R.id.buttonRegister_1);

buttonRegister_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = editTextName.getText().toString();
String email = editTextEmail.getText().toString();
String password = editTextPassword.getText().toString();

long rowID = userDAO.register(name, email, password);

if (rowID > 0) {
Toast.makeText(getActivity(), “Registration successful”, Toast.LENGTH_SHORT).show();

// вывод всех пользователей в лог
List<User> users = userDAO.getAllUsers();
Log.d(“UserDatabase”, “All users:”);
for (User user : users) {
Log.d(“UserDatabase”, user.toString());
}

getFragmentManager().popBackStack();
FragmentTransaction transaction = requireActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.nav_container, new FirstFragment());
transaction.addToBackStack(null);
transaction.commit();
} else if (rowID == -1) {
Toast.makeText(getActivity(), “Invalid email”, Toast.LENGTH_SHORT).show();

} else {
Toast.makeText(getActivity(), “Registration failed”, Toast.LENGTH_SHORT).show();
}
}
});
Button buttonLogin_1 = view.findViewById(R.id.buttonLogin_1);

buttonLogin_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentTransaction transaction = requireActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.nav_container, new LoginFragment());
transaction.addToBackStack(null);
transaction.commit();
}
});
Button buttonExit = view.findViewById(R.id.buttonExit);

buttonExit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

getFragmentManager().popBackStack();
FragmentTransaction transaction = requireActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.nav_container, new FirstFragment());
transaction.addToBackStack(null);
transaction.commit();
}
});


return view;
}

@Override
public void onDestroy() {
super.onDestroy();
userDAO.close();
}
}