i have an ArrayAdapter and i need to get the shared preferences of the app in order to do something with it. my problem i cant get the shared preferences.
thats my code:
public class MobileArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] values;
private static SharedPreferences prefs;
private String firstBtName = "";
private String secondBtName = "";
private String thirdBtName = "";
public MobileArrayAdapter(Context context, String[] values) {
super(context, R.layout.list, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
prefs = getSharedPreferences("MYPREFS", 0); // ERROR **************
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.list, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
textView.setText(values[position]);
eclips says that i dont have that cind of method…
What can i do? Thanks!
your error is because ArrayAdapter doesn’t have a
getSharedPreferences()method, Change the line that is giving you the error to this: