I have made a shared preference activity that store the user settings, now i want to get values in a activity or normal java class.please provide a solution or example i have already tried this code but failed.
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
SharedPreferences channel=this.getSharedPreferences(strFile, Context.MODE_PRIVATE);
strChannel=channel.getString(keyChannel,"Default").toString();
Toast.makeText(getApplicationContext(), strChannel, Toast.LENGTH_LONG).show();
}
in this code strfile
for eg. com.android.pack.ClassName
is SharedPreference Activity
from values to be fetched, and keyChannel is key that is same in SharedPreference Activity
.
Kindly provide the solution.