Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:03:12+00:00 2026-06-07T07:03:12+00:00

I am trying to access shared preferences from a service. I have used the

  • 0

I am trying to access shared preferences from a service. I have used the the following to save the value of text to a string…

SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("Ignore1_value", Example.getText().toString());
editor.commit();

But, how would i get the value in a service? Everything i have tried returns as nothing. Any help would be perfect and much appreciated?

I looked through some other questions as well with no solution. I have came up with this, but like i said it returns it as no text.

Context ctx = getApplicationContext();
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
    String example1string = sharedPreferences.getString("Ignore1_value","");
    Log.i("**GetSettings", example1string);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:03:14+00:00Added an answer on June 7, 2026 at 7:03 am

    I’m always using PreferenceManager.getDefaultSharedPreferences(context). This is the same for all Contexts in your application.

    A Service is a Context itself, so this would be sufficient:

    PreferenceManager.getDefaultSharedPreferences(this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that is trying to access images from a shared
I have some information stored as SharedPreferences. I need to access that information from
I have: Page.aspx Page.aspx.vb TestClass.vb I'm trying to access a shared property of the
I'm trying to save and load a String to/from the internal storage in a
I'm trying to access a shared object created by one flash application from another
I am getting a DllNotFoundException while trying to access my shared library from the
I have a public shared function and I'm trying to access the values of
I'm trying to implement shared preferences to be called from two different Activities. One
I'm trying to access a REST service from a function written in the custom
Trying to access a Servlet from a button on HTML page //Html Page FORM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.