Android sharedpreference logout don't clear values
<p>When I'm testing my login on my mobile app the <code>editor.clear();</code> is not working i guess because whenever I logout and click login without any values on my username and password it still logs in the previous one can you guys help me fix my problem? Here are my codes.</p>

<h1>loginFragment</h1>

<pre><code>public class loginFragment extends Fragment implements CompoundButton.OnCheckedChangeListener {

final String TAG = this.getClass().getName();
Button btnLogin;
EditText etUsername, etPassword;
TextView tvRegister;
CheckBox cbRemember;
SharedPreferences pref;
SharedPreferences.Editor editor;
boolean checkFlag;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_login, container, false);

    etUsername = (EditText) v.findViewById(R.id.etFirstname);
    etPassword = (EditText) v.findViewById(R.id.etPassword);
    btnLogin = (Button) v.findViewById(R.id.btnLogin);
    tvRegister = (TextView) v.findViewById(R.id.tvRegister);
    cbRemember = (CheckBox) v.findViewById(R.id.cbRemember);
    cbRemember.setOnCheckedChangeListener(this);
    checkFlag = cbRemember.isChecked();
    etUsername.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d(TAG, etUsername.getText().toString());
        }
    });

    pref = getActivity().getSharedPreferences("Login.conf", Context.MODE_PRIVATE);
    editor = pref.edit();

    final String username = pref.getString("username", "");
    final String password = pref.getString("password", "");

    HashMap postData = new HashMap();
    postData.put("username", username);
    postData.put("password", password);

    if (!username.equals("") &amp;&amp; (!password.equals(""))) {
        PostResponseAsyncTask task1 = new PostResponseAsyncTask(getActivity(), postData,
                new AsyncResponse() {
                    @Override
                    public void processFinish(String s) {

                        if (s.contains("renter")) {
                            Log.d(TAG, s);

                            Toast.makeText(getActivity(), "Renter Login Successful!", Toast.LENGTH_SHORT).show();
                            Intent in = new Intent(getActivity(), RenterTabs.class);
                            startActivity(in);
                            getActivity().finish();

                        } else if (s.contains("owner")) {
                            Log.d(TAG, s);
                            Toast.makeText(getActivity(), "Owner Login Successful!", Toast.LENGTH_SHORT).show();
                            Intent in = new Intent(getActivity(), OwnerTabs.class);
                            startActivity(in);
                            getActivity().finish();
                        } else {
                            Toast.makeText(getActivity(), "Wrong username or password...", Toast.LENGTH_SHORT).show();
                        }

                    }
                });
        task1.execute("http://carkila.esy.es/carkila/authenticate.php");
    }

    btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            HashMap postData = new HashMap();


            postData.put("username", etUsername.getText().toString());
            postData.put("password", MD5.encrypt(etPassword.getText().toString()));

            PostResponseAsyncTask task1 = new PostResponseAsyncTask(getActivity(), postData,
                    new AsyncResponse() {
                        @Override
                        public void processFinish(String s) {
                            Log.d(TAG,s);
                            if (s.contains("renter")) {
                                if (checkFlag) {

                                    editor.putString("username", etUsername.getText().toString());
                                    editor.putString("password", MD5.encrypt(etPassword.getText().toString()));
                                    editor.apply();

                                    Log.d(TAG, pref.getString("password", ""));
                                }


                                Intent in = new Intent(getActivity(), RenterTabs.class);
                                startActivity(in);
                                getActivity().finish();

                            } else if (s.contains("owner")) {

                                if (checkFlag) {

                                    editor.putString("username", etUsername.getText().toString());
                                    editor.putString("password", MD5.encrypt(etPassword.getText().toString()));

                                    editor.apply();
                                }

                                editor.putString("username", etUsername.getText().toString());
                                editor.putString("password", MD5.encrypt(etPassword.getText().toString()));
                                editor.apply();

                                Intent in = new Intent(getActivity(), OwnerTabs.class);
                                startActivity(in);
                                getActivity().finish();
                            } else {
                                Toast.makeText(getActivity(), "Wrong username or password...", Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
            task1.execute("http://carkila.esy.es/carkila/authenticate.php");
        }
    });

    tvRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent in = new Intent(getActivity(), RegisterActivity.class);
            startActivity(in);
        }
    });
return v;
}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    checkFlag = isChecked;
    Log.d(TAG, "checkflag: " + checkFlag);
}
}
</code></pre>

<h1>Class with logout</h1>

<pre><code>public class OwnerTabs extends AppCompatActivity  {
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
SharedPreferences pref;
SharedPreferences.Editor editor;
FloatingActionButton fab;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_owner_tabs);


    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    pref = getSharedPreferences("Login.conf", Context.MODE_PRIVATE);

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(2);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent in = new Intent(OwnerTabs.this, InsertActivity.class);
            startActivity(in);
        }
    });

    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            switch (position){
                case 0:
                    fab.show();
                    break;

                default:
                    fab.hide();
                    break;
            }

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.menu_main,menu);
    return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if(id == R.id.action_logout){
        editor = pref.edit();
        editor.clear();
        editor.commit();
        Intent in = new Intent (getApplicationContext(), MainActivity.class);
        startActivity(in);
        finish();
    }

    return super.onOptionsItemSelected(item);
}
</code></pre>

<h1>authenticate.php</h1>

<pre><code>    &lt;?php 
require 'database-config.php';
session_destroy();

$username = "";
$password = "";

if(isset($_POST['username'])){
$username = $_POST['username'];
}
if (isset($_POST['password'])) {
$password = $_POST['password'];
}

$q = 'SELECT * FROM tbl_user WHERE username=:username AND password=:password';

$query = $dbh-&gt;prepare($q);

$query-&gt;execute(array(':username' =&gt; $username, ':password' =&gt; $password));

if($query-&gt;rowCount() == 0){
header('Location: Login.php?err=1');
}else{
$row = $query-&gt;fetch(PDO::FETCH_ASSOC);

$_POST['sess_user_id'] = $row['userID'];
$_POST['sess_userrole'] = $row['roles'];

if($_POST['sess_userrole'] == "renter"){
echo "renter";

}else if ($_POST['sess_userrole'] == "owner"){
echo "owner";

}
}
?&gt;          
</code></pre>

<h1>database.config.php</h1>

<pre><code>&lt;?php
$database = '****';
$host = '****';
$user = '****';
$pass = '****';

$dbh = new PDO("mysql:dbname={$database};host={$host}", $user, $pass);

try{
if(!$dbh){

  echo "unable to connect to database";
}
}catch (PDOException $e){
echo $e-&gt;getMessage();
}

?&gt;
</code></pre>