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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:06:41+00:00 2026-06-13T17:06:41+00:00

Can you please clarify me, what’s the best practice for this example: Activity1 does

  • 0

Can you please clarify me, what’s the best practice for this example:

Activity1 does INSERTS on SQLite and starts Activity2.

On Activity2, the user clicks on Back button and goes back to Activity1.
But instead of making INSERT, I want to make UPDATE to the data on SQLite.

How do I control, that user “came” back?

What’s the best practice?

  • 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-13T17:06:42+00:00Added an answer on June 13, 2026 at 5:06 pm

    Assume on button click you starting Activity 2

    public static final int YOURCONSTANTNUMBER = 77;
       //Button Value
     Button second = (Button)findViewById(R.id.firstButton);
     second.setOnClickListner(this);
    
    @Override
    public void onClick(View v)
    {
      switch(v.getId())
       {
          case R.id.btnSecondActivity:
          //Code for inserting data into database
          Intent secondactivity = new Intent(FirstActivity.this, SecondActivity.class);
          startActivity(secondactivity);
          break;
        }
    }
    

    In your second activity

    To take control over the back button use the below code

     @Override
     public void onBackPressed()
     {      
    //Code for update     
     } 
    

    EDIT

    Call your second activity with startActivityForResult() method which will let you know the result.

    In First Activity

        Intent secondactivity = new Intent(FirstActivity.this, SecondActivity.class);
        startActivityForResult(secondactivity,YOURCONSTANTNUMBER);
    

    Getting Result

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    
     super.onActivityResult(requestCode, resultCode, data);   
     switch(requestCode)
     {
     case YOURCONSTANTNUMBER:
         // It will execute if you returning from second activity 
         //Update you database here
         }
     }
    

    In Your Second Activity

    Call this method were appropriate setResult(YOURCONSTANTNUMBER);

    Hope it helps

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

Sidebar

Related Questions

Can someone please clarify using a SIMPLE user story the full slice of what
Can you clarify this please? public static void MyMethod() { var context= new MyModel.Entities();
Can anyone please clarify what this query will return ? SELECT TestCase FROM MyTable
Possible Duplicate: What exactly does database normalization do? Can someone please clarify data normalization?
Can someone please help to clarify? Also, please mention if there are other representation
Can please some tell me when does the above written error occurs. I just
Can someone please tell me what this means: 07-04 09:54:38.048: I/DetailActivity(15496): Title that is
Can someone please clarify the following; if a have the following model; presentation-->slide-->video where
Can you please clarify about the perimeter variable in the below class. I understand
Can anyone please clarify when we check equality on collections, equals() method is called

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.