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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:42:23+00:00 2026-05-24T23:42:23+00:00

I am new to android development and and I want to setup some of

  • 0

I am new to android development and and I want to setup some of application’s attributes based on Application first run after installation. Is there any way to find that the application is running for the first time and then to setup its first run attributes?

  • 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-05-24T23:42:24+00:00Added an answer on May 24, 2026 at 11:42 pm

    The following is an example of using SharedPreferences to achieve a ‘first run’ check.

    public class MyActivity extends Activity {
    
        SharedPreferences prefs = null;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            // Perhaps set content view here
    
            prefs = getSharedPreferences("com.mycompany.myAppName", MODE_PRIVATE);
        }
    
        @Override
        protected void onResume() {
            super.onResume();
    
            if (prefs.getBoolean("firstrun", true)) {
                // Do first run stuff here then set 'firstrun' as false
                // using the following line to edit/commit prefs
                prefs.edit().putBoolean("firstrun", false).commit();
            }
        }
    }
    

    When the code runs prefs.getBoolean(...) if there isn’t a boolean saved in SharedPreferences with the key “firstrun” then that indicates the app has never been run (because nothing has ever saved a boolean with that key or the user has cleared the app data in order to force a ‘first run’ scenario). If this isn’t the first run then the line prefs.edit().putBoolean("firstrun", false).commit(); will have been executed and therefore prefs.getBoolean("firstrun", true) will actually return false as it overrides the default true provided as the second parameter.

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

Sidebar

Related Questions

I am new to Android development and want to build a first sample application.
I am new to android development. I want to make one background application, so
hey, im new to android development and trying to make my first application. What
I am new to Android application development.I want to develop a simple android application
I'm new to android development In my application I want to keep log-in status
I am new to Android development and I want first to get the Hello
I'm pretty new to Android development and would appreciate some help. All I want
I everyone. I'm very new to Android development and I want to develop an
I am new to android development. I am creating an android application, in which
I am new to android development. Currently i am working on an application which

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.