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

  • Home
  • SEARCH
  • 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 8805291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:49:45+00:00 2026-06-14T01:49:45+00:00

I am using intent-extra in two different activities and is then storing them using

  • 0

I am using intent-extra in two different activities and is then storing them using ContentValue from a different activity using single bundle…but its showing me error….here’s the code of activity where i am using content value…

    package com.example.alert;

    import android.app.Activity;
    import android.content.ContentValues;
    import android.database.sqlite.SQLiteDatabase;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;

    public class StoringEntire extends Activity {
     DatabaseHelper db=new DatabaseHelper(this);
     public static String alerterName;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.storing_entire);
    Button save=(Button) findViewById(R.id.save);

    save.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            Bundle bundle=getIntent().getExtras();
            alerterName=bundle.getString("alerterName");
            double lat=bundle.getDouble("Latitude");
            double lon=bundle.getDouble("Longitude");
            SQLiteDatabase datab=db.getWritableDatabase();
            ContentValues cv=new ContentValues();
            cv.put(db.KEY_ALERT, alerterName);
            cv.put(db.KEY_LATITUDE,lat);
            cv.put(db.KEY_LONGITUDE, lon);
            datab.insert("data",db.KEY_ALERT,cv);
            datab.insert("data",db.KEY_LATITUDE,cv);
            datab.insert("data",db.KEY_LONGITUDE,cv);
            db.close();

        }
    });
}

}

- 11-09 03:17:23.939: E/AndroidRuntime(1012): FATAL EXCEPTION: main </n>
- 11-09 03:17:23.939: E/AndroidRuntime(1012): java.lang.NullPointerException
- 11-09 03:17:23.939: E/AndroidRuntime(1012): at com.example.alert.StoringEntire$1.onClick(StoringEntire.java:26)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at android.view.View.performClick(View.java:4084)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at android.view.View$PerformClick.run(View.java:16966)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at android.os.Handler.handleCallback(Handler.java:615)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at android.os.Handler.dispatchMessage(Handler.java:92)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at android.os.Looper.loop(Looper.java:137)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at android.app.ActivityThread.main(ActivityThread.java:4745)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at java.lang.reflect.Method.invokeNative(Native Method)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at java.lang.reflect.Method.invoke(Method.java:511)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
- 11-09 03:17:23.939: E/AndroidRuntime(1012):   at dalvik.system.NativeStart.main(Native Method)

these are the intents that I am using

    Intent myIntent = new Intent(AddLocation.this, AddTrigger.class);
           myIntent.putExtra("Latitude", ""+ destLatitude);
       myIntent.putExtra("Longitude",""+ destLongitude);

And for another activity

    Intent Inten = new Intent(AddAlerter.this, AddLocation.class);
                 Inten.putExtra("alerterName", alerterNameEditText.getText().toString());

                startActivity(Inten);
  • 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-14T01:49:46+00:00Added an answer on June 14, 2026 at 1:49 am

    You need to check for null values in your code and you are calling insert() three times, try this:

    public class StoringEntire extends Activity {
        DatabaseHelper db;
        public static String alerterName;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.storing_entire);
    
            db = new DatabaseHelper(this);
            Button save=(Button) findViewById(R.id.save);
            save.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if(getIntent() != null) {
                        Bundle bundle=getIntent().getExtras();
                        if(bundle != null) {
                            alerterName=bundle.getString("alerterName");
                            double lat=bundle.getDouble("Latitude");
                            double lon=bundle.getDouble("Longitude");
                            SQLiteDatabase datab=db.getWritableDatabase();
                            ContentValues cv=new ContentValues();
                            cv.put(db.KEY_ALERT, alerterName);
                            cv.put(db.KEY_LATITUDE,lat);
                            cv.put(db.KEY_LONGITUDE, lon);
                            datab.insert("data", null, cv);
                            db.close();
                        }
                    }
                }
            });
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I launch an activity from my widget using an Intent with some extra, anyway
In my application user can share information with different apps using: shareIntent.putExtra(Intent.EXTRA_SUBJECT, Link from
i want to pass data between two activities.In the first activity i m using
I am taking a high resolution picture through the default camera activity(using intent.put Extras
I'm trying to pass an int between two classes using a bundle. I have
I have an Android application that contains two Activities . Activity A has a
I am Using Following Code for Send the Email from my application but problem
While using Intent object we can put different types of data directly using its
I'm adding the ability to share scores from my app using android's share intent:
I am using Intent Service in my program. In the Intent Service, I have

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.