For the basic idea, see the code:
Java code:
MainActivity logIn= rember= auto= name= password= Intent intent= Intent(MainActivity.,NewMainActivity. test=getSharedPreferences("UserData" editor= (test.getBoolean("auto",)!= (test.getBoolean("rember", )!= ((temp=test.getString("name", ))!= ((temp=test.getString("password",)) != rember.setChecked( haved= logIn.setOnClickListener( (haved == editor.putBoolean("rember", editor.putString("name" editor.putString("password" (auto.isChecked()== editor.putBoolean("auto", }
Activity_main.xml
<RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" android: layout_width = "match_parent" android: layout_height = "match_parent" android: paddingBottom = "@ dimen/activity_vertical_margin" android: paddingLeft = "@ dimen/plugin" android: paddingRight = "@ dimen/plugin" android: paddingTop = "@ dimen/plugin" tools: context = ". mainActivity "> <android: id =" @ + id/name "android: layout_width =" match_parent "android: layout_height =" wrap_content "android: layout_alignLeft = "@ + id/password" android: layout_alignParentTop = "true" android: layout_marginTop = "16dp" android: EMS = "10"/> <android: id = "@ + id/password" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_below = "@ + id/name" android: layout_centerHorizontal = "true" android: layout_marginTop = "18dp" android: EMS = "10"> <requestFocus/> </EditText> <android: id = "@ + id/button1" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_alignLeft = "@ + id/password" android: layout_below = "@ + id/password" android: layout_marginLeft = "16dp" android: text = "login"/> <android: id = "@ + id/autoRunFlag" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_alignLeft = "@ + id/password" android: layout_below = "@ + id/button1" android: text = "automatic login"/> <android: id = "@ + id/remberFlag" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_alignBaseline = "@ + id/autoRunFlag" android: layout_alignBottom = "@ + id/autoRunFlag" android: layout_alignRight = "@ + id/password" android: text = "Remember password"/> </RelativeLayout>
Activity_second.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"="http://schemas.android.com/tools"="match_parent"="match_parent"="@dimen/activity_vertical_margin"="@dimen/activity_horizontal_margin"="@dimen/activity_horizontal_margin"="@dimen/activity_vertical_margin"=".MainActivity" > <="@+id/ratingBar1"="wrap_content"="wrap_content"="true"="true"="170dp" /></RelativeLayout>
To register in AndroidMainifest: