SharedPreferences getBoolean - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SharedPreferences getBoolean method.

This code example shows how to use the following methods:getBoolean
		} 
	} 
 
	@Override 
	public boolean getBoolean (String key) {
		return sharedPrefs.getBoolean(key, false);
	} 
 
	@Override 
	public int getInteger (String key) {
		return sharedPrefs.getInt(key, 0);
	} 
 
	@Override 
	public long getLong (String key) {
		return sharedPrefs.getLong(key, 0);
	} 
 
	@Override 
	public float getFloat (String key) {
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBoolean, getLong
		} 
		// If a lock pattern is set we need to check the time for when the last 
		// activity was open. If it's been more than two seconds the user 
		// will have to enter the lock pattern to continue. 
		long currentTime = SystemClock.elapsedRealtime();
		long lockedAt = mPrefs.getLong("locked_at", currentTime-10000);
		long timedif = Math.abs(currentTime - lockedAt);
		if (timedif > 2000) {
		    launchPatternLock(); 
		} 
        else { 
            mHasLoaded = true;          
        } 
	} 
 
	private void launchPatternLock() { 
        Intent intent = new Intent(this, ConfirmLockPattern.class);
        intent.putExtra(ConfirmLockPattern.DISABLE_BACK_KEY, true);
        intent.putExtra(ConfirmLockPattern.HEADER_TEXT, getText(R.string.patternlock_header));
        startActivityForResult(intent, PATTERNLOCK_UNLOCK);         

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:edit, getBoolean, getInt, getLong
     * @return the wall clock time ({@link System#currentTimeMillis()}) when the 
     * next operation should be attempted -- immediately, if the return value is 
     * before the current time. 
     */ 
    public long getNextTimeMillis(Options options) {
        boolean enabledState = mStorage.getBoolean(PREFIX + "enabledState", true);
        if (!enabledState) return Long.MAX_VALUE;
 
        boolean permanentError = mStorage.getBoolean(PREFIX + "permanentError", false);
        if (permanentError) return Long.MAX_VALUE;
 
        // We do quite a bit of limiting to prevent a clock rollback from totally 
        // hosing the scheduler.  Times which are supposed to be in the past are 
        // clipped to the current time so we don't languish forever. 
 
        int errorCount = mStorage.getInt(PREFIX + "errorCount", 0);
        long now = currentTimeMillis();
        long lastSuccessTimeMillis = getTimeBefore(PREFIX + "lastSuccessTimeMillis", now);
        long lastErrorTimeMillis = getTimeBefore(PREFIX + "lastErrorTimeMillis", now);
        long triggerTimeMillis = mStorage.getLong(PREFIX + "triggerTimeMillis", Long.MAX_VALUE);

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:edit, getBoolean, getLong
    private final static int LAUNCHES_UNTIL_PROMPT = 7;
     
    public static void appLaunched(Context mContext) {
        SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);
 
        if (prefs.getBoolean("dontshowagain", false)) { return ; }
         
        SharedPreferences.Editor editor = prefs.edit();
         
        // Increment launch counter 
        long launch_count = prefs.getLong("launch_count", 0) + 1;
        editor.putLong("launch_count", launch_count);
 
        // Get date of first launch 
        Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
        if (date_firstLaunch == 0) {
            date_firstLaunch = System.currentTimeMillis();
            editor.putLong("date_firstlaunch", date_firstLaunch);
        } 
         

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBoolean
		editor.putBoolean(PREF_FIRSTRUN, value);
		editor.commit();
	} 
 
	public Boolean isPrependDateEnabled() {
		return m_prefs.getBoolean(prepend_date_pref_key, true);
	} 
 
	public boolean isManualModeEnabled() { 
		try { 
			long period = Long.parseLong(m_prefs.getString(
					periodic_sync_pref_key, "0"));
 
			return period < 0;
		} catch (NumberFormatException ex) {
			return false; 
		} 
	} 
 
	public boolean needToPush() { 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBoolean
	private SharedPreferences appSettings;
 
	private boolean shouldStartService(Context context) {
		this.appSettings = PreferenceManager
				.getDefaultSharedPreferences(context.getApplicationContext());
		return this.appSettings.getBoolean("doAutoSync", false);
	} 
 
	@Override 
	public void onReceive(Context context, Intent intent) {
		if (this.shouldStartService(context)) {
			SyncService.startAlarm(context);
		} 
		 
		Intent calIntent = new Intent(context, CalendarSyncService.class);
		calIntent.putExtra(CalendarSyncService.FILELIST, new String[] {});
		context.startService(calIntent);
	} 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:edit, getBoolean
	} 
 
	public void showOnFirstRun() { 
		String versionKey = "changelog_" + AndroidUtils.getAppVersionCode(mContext);
 
		if (!mPrefs.getBoolean(versionKey, false)) {
			showChangelogDialog(); 
 
			Editor editor = mPrefs.edit();
			editor.putBoolean(versionKey, true);
			editor.commit();
		} 
	} 
 
	private void showChangelogDialog() { 
 
		String changelog = getChangelogFromResources();
 
		WebView webView = new WebView(mContext);
		webView.loadData(changelog, "text/html", "utf-8");
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:edit, getBoolean
        prefs = getSharedPreferences("torch", Context.MODE_WORLD_READABLE);
        Log.i(TAG, "onCreate");
    } 
 
    private void toggleTorch() { 
        if (prefs.getBoolean(KEY_TORCH_ON, false)) // find torch state
            stopTorch(); // torch is on - turn it off 
        else 
            startTorch(); // torch is off, turn it on 
    } 
 
    private void startTorch() { 
        if (!startingTorch) {
            startingTorch = true;
            getCamera(); 
            startPreview(); 
            turnLightOn(); 
            SharedPreferences.Editor editor = prefs.edit();
            editor.putBoolean(KEY_TORCH_ON, true);
            editor.commit();

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:edit, getBoolean, getInt
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBoolean, getString
		syncThread.start();
	} 
 
 
	private void setAlarm() { 
		boolean doAutoSync = this.appSettings.getBoolean("doAutoSync", false);
		if (!this.alarmScheduled && doAutoSync) {
 
			int interval = Integer.parseInt(
					this.appSettings.getString("autoSyncInterval", "1800000"),
					10); 
 
			this.alarmIntent = PendingIntent.getService(appInst, 0, new Intent(
					this, SyncService.class), 0);
			alarmManager.setRepeating(AlarmManager.RTC,
					System.currentTimeMillis() + interval, interval,
					alarmIntent);
 
			this.alarmScheduled = true;
		} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related SharedPreferences getBoolean Questions & Answers:

Other SharedPreferences getBoolean Examples

348:		private boolean isTwitterLoggedInAlready() {
349:			// return twitter login status from Shared Preferences
350:			return mSharedPreferences.getBoolean(PREF_KEY_TWITTER_LOGIN, false);
351:		}
352:

Read More

120:		// Get Login State
121:		public boolean isLoggedIn(){
122:			return pref.getBoolean(IS_LOGIN, false);
123:		}
124:	}

Read More

getBoolean Method Overview
Retrieve a boolean value from the preferences.
See Code Examples for other Android SharedPreferences Methods: