I have given this to save data with sharedpreference
so I want to get value to a spinner, here I have given this
SharedPreferences spf = getSharedPreferences("myprfs", Context.MODE_PRIVATE);
String ret = spf.getString("ctyp","");
Here am getting the value to a String, I want to assign a same value to a spinner.
for(int i=0;i<2;i++)
if(ret.equals(spinner.getItemAtPosition(i).toString())){
spinner.setSelection(i);
break;
}
I am getting this error
'java.lang.Object android.widget.Spinner.getItemAtPosition(int)' on a null object reference
Can any one suggest me correct ans..