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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:39:55+00:00 2026-05-27T19:39:55+00:00

//hi i am trying to retrieve the data from database and display in my

  • 0
//hi i am trying to retrieve the data from database and display in my activity.but it is giving error fatal exception main.here when i click showall button all student details shouls get dispalyed.


public class four extends Activity {
    Button showall;
    MyDataBase mydb;
    ListView lv;
    int str;

    public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.snd);

         mydb=new MyDataBase(four.this);
            mydb.openDB();




    showall.setOnClickListener(new OnClickListener(){


        public void onClick(View v) {

            Log.i("INFO","ALL DETAILS");
            ArrayList<HashMap<String,String>> p2 = mydb.getAllSDetails();

                lv = (ListView)findViewById(R.id.listView1);

    //coloum.xml contains four text view,and string contains my coloum names.

               SimpleAdapter mSchedule = new SimpleAdapter(four.this, p2, R.layout.column,
                       new String[] {"_Sid","FName", "LName","clss","sec"}, new int[] {R.id.txtfname, R.id.txtlname,R.id.txtage,R.id.txtqual});
               lv.setAdapter(mSchedule);



                lv.setOnItemClickListener(select);

            }
        });
    }

            public OnItemClickListener select=new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int position,
                        long arg3) {
                    int idd[] = mydb.gettingId();
                    str = idd[position];


                }

              };
}

// my error log .i am unable to solve the problem.is there any thing wrong i did in my program. my error log .i am unable to solve the problem.is there any thing wrong i did in my program. can any one please guide me why i am getting the following error.

2-27 08:26:12.098: I/INFO(381): ALL DETAILS
12-27 08:26:12.098: I/INFO(381): database creation
12-27 08:26:12.108: I/INFO(381): Opening database
12-27 08:26:12.148: I/INFO(381): ALL DETAILS
12-27 08:26:12.158: D/AndroidRuntime(381): Shutting down VM
12-27 08:26:12.158: W/dalvikvm(381): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-27 08:26:12.180: E/AndroidRuntime(381): FATAL EXCEPTION: main
12-27 08:26:12.180: E/AndroidRuntime(381): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android/com.android.four}: java.lang.NullPointerException
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.os.Looper.loop(Looper.java:123)
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-27 08:26:12.180: E/AndroidRuntime(381):  at java.lang.reflect.Method.invokeNative(Native Method)
12-27 08:26:12.180: E/AndroidRuntime(381):  at java.lang.reflect.Method.invoke(Method.java:521)
12-27 08:26:12.180: E/AndroidRuntime(381):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-27 08:26:12.180: E/AndroidRuntime(381):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-27 08:26:12.180: E/AndroidRuntime(381):  at dalvik.system.NativeStart.main(Native Method)
12-27 08:26:12.180: E/AndroidRuntime(381): Caused by: java.lang.NullPointerException
12-27 08:26:12.180: E/AndroidRuntime(381):  at com.android.four.onCreate(four.java:40)
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-27 08:26:12.180: E/AndroidRuntime(381):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-27 08:26:12.180: E/AndroidRuntime(381):  ... 11 more
  • 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-27T19:39:55+00:00Added an answer on May 27, 2026 at 7:39 pm

    I think you have not initialized your button “showall“.

    Something like

    showall=(Button)findviewbyid(R.id.yourbuttonid);
    

    are you missing this?

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

Sidebar

Related Questions

Iam trying to retrieve data from mysql database into stylesheet.php but it is not
i am trying to retrieve data from a database and display then on a
I'm trying to retrieve hierarchical data from a table but am failing to do
I am trying to fetch data from my database and when I display it
Hi i am trying to retrieve data from mysql database to create flot graph
I am trying to retrieve data from mysql then display it on android listview.
I've been having problems trying to retrieve data from my database to a DataTable
I am trying to retrieve some data from a database using jQuery's $.getJSON method
I am basically trying to retrieve some data from a MySql server, and display
I'm trying to retrieve data from an SQL Server 2000 server, and place into

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.