获得以name为名的preferences文件,返回SharedPreferences可修改其值.它是单例模式.
Parameters
name Desired preferences file. If a preferences file by this name does not exist, it will be created when you retrieve an editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
根据name获得SharedPreferences实例,如果不存在,则自动创建.通过SharedPreferences.edit()来编辑,然后Editor.commit()提交后才会改变
mode Operating mode. Use 0 or MODE_PRIVATE for the default operation, MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE to control permissions. The bit MODE_MULTI_PROCESS can also be used if multiple processes are mutating the same SharedPreferences file. MODE_MULTI_PROCESS is always on in apps targetting Gingerbread (Android 2.3) and below, and off by default in later versions. ReturnsReturns the single SharedPreferences instance that can be used to retrieve and modify the preference values.
返回一个单例SharedPreferences,可以恢复和修改preference的值
See Also MODE_PRIVATE MODE_WORLD_READABLE MODE_WORLD_WRITEABLEMODE_MULTI_PROCESS
---------------------------------------------------------------------------------------------------------------------------
boolean android.content.SharedPreferences.getBoolean(String key, boolean defValue) public abstract boolean getBoolean (String key, boolean defValue) Since: API Level 1 Retrieve a boolean value from the preferences. 从preferences里面取回一个boolean值 Parameters key The name of the preference to retrieve. 根据name取回 defValue Value to return if this preference does not exist. 如果不存在这个name,则返回defValue Returns Returns the preference value if it exists, or defValue. Throws ClassCastException if there is a preference with this name that is not a boolean.如果存在则返回,或者defValue,如果不是boolean值,则报ClassCastException Throws ClassCastException
------------------------------------------------------------------------------------------------
public abstract ContentResolver getContentResolver () Since: API Level 1 Return a ContentResolver instance for your application's package.
mCloseFlag=false
mContentProvider=android.content.ContentProvider$Transport@44db41c8
mSQLiteCursor=android.database.sqlite.SQLiteCursor@44dbfd00
12-02 06:23:02.788: V/AlarmClock(292): android.content.ContentResolver$CursorWrapperInner@44dc0230
数据在android中是私有的,当然这而数据包括文件数据和数据库数据以及一些其他类型的数据。那么两个程序之间如何进行数据交换呢?解决这个问题主要靠ContentProvider。一个ContentProvider类实现了一组标准的方法接口,从而能够让其他的应用保存或读取此Content Provider的各种数据类型。也就是说一个程序可以通过实现ContentProvider的抽象接口将自己的数据暴露出去。外界根本看不到,也就不用看到这个应用暴露的数据在应用当中如何存储的,或者是用数据库存储还是文件存储,还是网络存储。外界可以通过这套标准及统一的接口和程序中的数据打交道,可以操作程序中的数据。
外界的程序通过ContentResolver接口可以访问ContentProvider提供的数据,在Activity当中通过getContentResolver可以得到当亲的ContentResolver实例。ContentResolver提供的接口和ContentProvider中需要实现的接口对应。在ContentResolver中到相应的接口的话,ContentProvider会执行相应的接口,把结果返回。