I have few problems with syntax errors here. Below I have an alertDialog with sharedPreference and if you are wonder why I have this in a asynctask you can see this Shared Prefence for alert dialog is making my application non responsive But the syntax problem is underneath installed in my onPostExecute and it says "installed cannot be resovled to a variable." I also have another one under settings in my onPostExecute that says the same thing as well. I know this may seem like an easy fix to some people but I find this really complicated for someone like me. I also advice you look at the link if you have a better method than the AsyncTask and onResume()
@Override
protected void onResume() {
class asynctask extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... arg0) {
final SharedPreferences settings = getSharedPreferences("pref_name", 0);
boolean installed = settings.getBoolean("installed", false);
return null;
}}}
protected void onPostExecute(String file_ad) {
if(!installed){
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("Title");
alertDialog.setIcon(R.drawable.ic_launcher);
alertDialog.setAdapter(new MyAdapter(), null);
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("installed", true);
editor.commit();
}
});
alertDialog.show();
}
super.onResume();
}