Note that there are some explanatory texts on larger screens.

plurals
  1. POSharedPreferences.Editor (Android) confusion
    primarykey
    data
    text
    <p>To be honesr, I'm not really sure how to set the title for this. I'm learning <a href="http://developer.android.com/training/basics/data-storage/shared-preferences.html" rel="nofollow">http://developer.android.com/training/basics/data-storage/shared-preferences.html</a> and would like to make things clear a little bit.</p> <p>Lets say we have:</p> <pre><code>SharedPreferences sharedPref = getSharedPreferences(USERNAME, MODE_PRIVATE); </code></pre> <p>and</p> <pre><code>SharedPreferences.Editor editor = sharedPref.edit(); </code></pre> <p>When I hover the mouse on edit() (I use Eclipse IDE), I learned that</p> <blockquote> <p>Open Declaration Editor android.content.SharedPreferences.edit()</p> <p>public abstract SharedPreferences.Editor edit ()</p> <p>Added in API level 1</p> <p>Create a new Editor for these preferences, through which you can make modifications to the >data in the preferences and atomically commit those changes back to the SharedPreferences >object. </p> <p>Note that you must call commit() to have any changes you perform in the Editor actually show up in the SharedPreferences.</p> <p>Returns Returns a new instance of the SharedPreferences.Editor interface, allowing you to modify the values in this SharedPreferences object. </p> </blockquote> <p>So I actually have 3 small questions here:</p> <p>1/ edit() is an abstract method, so in what class has edit() been overriden (I've already learned that "public abstract SharedPreferences.Editor edit()" located in SharedPreferences interfaces, so there must be some class out there implements this interface)</p> <p>2/ SharedPreferences.Editor is an interface. As far as I known, an interface can not be instantiated. How come this editor object above can receive "a new instance of the SharedPreferences.Editor interface" as stated in the API.</p> <p>3/ I just start to learn Android for a few days, is it a good approach that I learn in this way, which mean dissecting everything to make them clear to me?</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload