Saved Preference not getting retrieved
<p>I have a video downloader class in my project that downloads videos from the given url and saves preference as true upon download completion. I check the preference if it's true in another class to fetch the video for playback from it's path. The downloader first checks if the file is downloaded like this:</p>

<pre><code>string isVideoDownloaded = Utils.readPreferences(ctx, video.getUrl(), "false");
            bool isVideoAvailable = Boolean.Parse(isVideoDownloaded);
</code></pre>

<p>When the download is completed, the following code is executed.</p>

<pre><code>                    activity.RunOnUiThread(() =&gt;
                 {
                     Utils.savePreferences(ctx, video.getUrl(), "true");
                 });
</code></pre>

<p>The preference is saved in the following manner:</p>

<pre><code>        public static void savePreferences(Context activity, string key, string defaultValue)
    {
        ISharedPreferences sp = PreferenceManager.GetDefaultSharedPreferences(activity.ApplicationContext);
        ISharedPreferencesEditor editor = sp.Edit();
        editor.Clear();
        editor.PutString(key, defaultValue);
        editor.Commit();
    }
</code></pre>

<p>Before playing back the video, the preference is checked in the following method:</p>

<pre><code>private bool isVideoDownloaded(Video video)
    {

        string isVideoDownloaded = Utils.readPreferences(context, video.getUrl(), "false");
        bool isVideoAvailable = Boolean.Parse(isVideoDownloaded);
        if (isVideoAvailable)
        {
            //If video is downloaded then hide its progress
            hideProgressSpinner(video);
            return true;
        }

        showProgressSpinner(video);
        return false;
    }
</code></pre>

<p>But the preference is always returned as false. I'm using the same context for the payback I am for the download. This code worked the first time I wrote it but now every time it returns false.
I'm a beginner with android so I'm having a hard time figuring out what I'm doing wrong here and how I can fix it.</p>

<p>What can I do to make it work? Any help is appreciated.</p>