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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:56:27+00:00 2026-06-12T13:56:27+00:00

When i try to open a activity in my app which its suposed to

  • 0

When i try to open a activity in my app which its suposed to show some saved messages(that i saved in another activity in the same app) it Force to Close and shows me these errors in LogCat:

  10-08 18:22:17.243: E/AndroidRuntime(269): FATAL EXCEPTION: main
  10-08 18:22:17.243: E/AndroidRuntime(269): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mensagem/com.example.mensagem.Mensagenssalvas}: java.lang.NullPointerException
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.os.Handler.dispatchMessage(Handler.java:99)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.os.Looper.loop(Looper.java:123)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.app.ActivityThread.main(ActivityThread.java:4627)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at java.lang.reflect.Method.invokeNative(Native Method)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at java.lang.reflect.Method.invoke(Method.java:521)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at dalvik.system.NativeStart.main(Native Method)
  10-08 18:22:17.243: E/AndroidRuntime(269): Caused by: java.lang.NullPointerException
  10-08 18:22:17.243: E/AndroidRuntime(269):    at com.example.mensagem.Mensagenssalvas.Mensagens(Mensagenssalvas.java:41)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at com.example.mensagem.Mensagenssalvas.onCreate(Mensagenssalvas.java:26)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  10-08 18:22:17.243: E/AndroidRuntime(269):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  10-08 18:22:17.243: E/AndroidRuntime(269):    ... 11 more

Before i use the code in this LINK it was normal but after i used the code, my databasecolumn is now not opening in the activity i try to open.(which is meant to show the messages).

Mensagenssalvas.java

 public class Mensagenssalvas extends Activity {

    public SQLiteDatabase db;

    ArrayList<String> list = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mensagenssalvas);
    db = openOrCreateDatabase("banco.db", Context.MODE_WORLD_WRITEABLE, null);

    Mensagens();
}

private void Mensagens() {
    // TODO Auto-generated method stub

    ListView user = (ListView) findViewById(R.id.lvMensagens);

    String[] campos = new String[] {"mensagemsalva", "mensagemenviada"};

    list = new ArrayList<String>();
    Cursor c = db.query( "mensagens", campos, null, null, null, null, null);
    c.moveToFirst();
    if(c.getCount() > 0) {
        while(true) {
           list.add(c.getString(c.getColumnIndex("mensagemsalva")).toString());
            if(!c.moveToNext()) break;
        }
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, list);

    user.setAdapter(adapter);

   }
}
  • 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-12T13:56:28+00:00Added an answer on June 12, 2026 at 1:56 pm

    You need to check line 41 of your Mensagenssalvas.java
    and find out what caused the NullPointerException.

    In many cases you just forgot to initialize it.

    to fix:
    Do not set what ever you want to use to NULL,
    in stead, set it to 0, or “”, depending on what type it is.
    You need to set to something that has a “EMPTY” or “ZERO” value, but not NULL.

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

Sidebar

Related Questions

I am coding an app that give me some problems. I have an activity
I try to open a finder window which works fine but every time I
I'm having some trouble getting the adobe reader app to open a pdf in
I am implementing an app that uses the native language settings which can be
Ok so, I have my app which so far opens a new Activity from
I have a native android app in which there are two activities, 1st activity
I try open and play .wav files with NAudio lib. private OpenFileDialog openFileDialog =
when I try to open a file for reading in my console application i
When I try to open a file in write mode with the following code:
When I try to open the following video: http://streaming1.hss-win.rpi.edu/ondemand/cogsci/issues_in_cs/issues_in_cogsci_02_04_2009.asf I can get it but

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.