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 8546507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:02:34+00:00 2026-06-11T13:02:34+00:00

I’ve asked this before, but my understanding has increased slightly. I’ve figured out how

  • 0

I’ve asked this before, but my understanding has increased slightly. I’ve figured out how to get the user to choose a custom background image on a layout. I use this:

in my onCreate method:

Button player = (Button) setBg.findViewById(R.id.plBg);

                player.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {

                        Intent i = new Intent(Intent.ACTION_PICK, 
                                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

                        i.setDataAndType(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, "image/*");                                      
                        startActivityForResult(i, RESULT_LOAD_PLAYER);

                        setBg.dismiss();
                    }
                });

and in my onActivityResult method:

    @Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

if (requestCode == RESULT_LOAD_PLAYER && resultCode == RESULT_OK && null != data) {
         Uri selectedImage = data.getData();
         String[] filePathColumn = {MediaStore.Images.Media.DATA};

         Cursor cursor = getContentResolver().query(selectedImage,
                 filePathColumn, null, null, null);
         cursor.moveToFirst();

         int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
         String picturePath = cursor.getString(columnIndex);
         cursor.close();

         playerBg = (ImageView) findViewById(R.id.playerBg);
         playerBg.setImageBitmap(BitmapFactory.decodeFile(picturePath));
         playerBg.setScaleType(ScaleType.CENTER_CROP);
     }
}

but when you ‘back’ out of the app, the background reverts back to default. how do I get that background choice to stick?

I’ve already look at this: Save bitmap to location

But I have a hard time understand it.
I’ve also tried getting it to save in shared preferences but learned that that’s not what they’re for.
I’m still a beginner that this. Thanks in advance.

  • 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-11T13:02:36+00:00Added an answer on June 11, 2026 at 1:02 pm

    IMO, you can have flag(boolean var) in sharedpreference which indicates that user set any background or not? And also, if user set any background then you can save the picture path in sharedpreference. So, every time when your activity starts which onCreate(). You check the flag from sharedpref and set the background using the picture path saved in shared pref.

    Also, I agree with matheszabi, you need to know more about android lifecycle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has

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.