-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsharedP
41 lines (38 loc) · 1.21 KB
/
sharedP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import android.content.Context;
import android.content.SharedPreferences;
public class SharedPreferenceHelper {
private SharedPreferences sharedPreferences;
public SharedPreferenceHelper(Context context) { sharedPreferences = context.getSharedPreferences("ProfilePreference",
Context.MODE_PRIVATE );
}
public void saveProfileName(String name)
{
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("profileName",name );
editor.commit();
}
public void saveProfileAge(String Age)
{
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("profileAge",Age );
editor.commit();
}
public void saveProfileID(String id)
{
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("profileID",id );
editor.commit();
}
public String getProfileName()
{
return sharedPreferences.getString("profileName", null);
}
public String getProfileAge()
{
return sharedPreferences.getString("profileAge", null);
}
public String getProfileID()
{
return sharedPreferences.getString("profileID", null);
}
}