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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:23:22+00:00 2026-06-09T04:23:22+00:00

I’m wondering why can’t I open my app. Plus, I’m trying to retrieve data

  • 0

I’m wondering why can’t I open my app. Plus, I’m trying to retrieve data from SQLite database and insert into spinner.

The LogCat says:

08-06 09:37:41.262: I/dalvikvm(532): threadid=3: reacting to signal 3
08-06 09:37:41.343: I/dalvikvm(532): Wrote stack traces to '/data/anr/traces.txt'
08-06 09:37:41.643: D/gralloc_goldfish(532): Emulator without GPU emulation detected.
08-06 09:37:41.773: I/dalvikvm(532): threadid=3: reacting to signal 3
08-06 09:37:41.793: I/dalvikvm(532): Wrote stack traces to '/data/anr/traces.txt'
08-06 09:37:43.293: D/AndroidRuntime(532): Shutting down VM
08-06 09:37:43.303: W/dalvikvm(532): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
08-06 09:37:43.312: E/AndroidRuntime(532): FATAL EXCEPTION: main
08-06 09:37:43.312: E/AndroidRuntime(532): java.lang.RuntimeException: Unable to start activity ComponentInfo{main.page/main.page.PersonalInfo}: java.lang.NullPointerException
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.os.Looper.loop(Looper.java:137)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.app.ActivityThread.main(ActivityThread.java:4424)
08-06 09:37:43.312: E/AndroidRuntime(532):  at java.lang.reflect.Method.invokeNative(Native Method)
08-06 09:37:43.312: E/AndroidRuntime(532):  at java.lang.reflect.Method.invoke(Method.java:511)
08-06 09:37:43.312: E/AndroidRuntime(532):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-06 09:37:43.312: E/AndroidRuntime(532):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-06 09:37:43.312: E/AndroidRuntime(532):  at dalvik.system.NativeStart.main(Native Method)
08-06 09:37:43.312: E/AndroidRuntime(532): Caused by: java.lang.NullPointerException
08-06 09:37:43.312: E/AndroidRuntime(532):  at main.page.InfoDBAdapter.getAllContacts(InfoDBAdapter.java:113)
08-06 09:37:43.312: E/AndroidRuntime(532):  at main.page.PersonalInfo.onCreate(PersonalInfo.java:41)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.app.Activity.performCreate(Activity.java:4465)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-06 09:37:43.312: E/AndroidRuntime(532):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
08-06 09:37:43.312: E/AndroidRuntime(532):  ... 11 more
08-06 09:37:43.694: I/dalvikvm(532): threadid=3: reacting to signal 3
08-06 09:37:43.713: I/dalvikvm(532): Wrote stack traces to '/data/anr/traces.txt'
08-06 09:37:43.923: I/dalvikvm(532): threadid=3: reacting to signal 3
08-06 09:37:43.933: I/dalvikvm(532): Wrote stack traces to '/data/anr/traces.txt'

Below is the codes for retrieving the data from database and put into spinner.

@Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.info);

        Cursor c = infoDB.getAllContacts();
        startManagingCursor(c);

        //Create an array to specify which fields want to display
        String[] from = new String[] {"name"};

        //Create an array of the display item want to bind our data to
        int[] to = new int[] {R.id.fName};

        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, from, to);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        nameSpinner.setAdapter(adapter);

        nameSpinner = (Spinner) findViewById(R.id.nameSpinner);

Oh yeah, before I typed in the codes(the one above), I can open the app. But after I typed in the codes, I can’t open the app. I’m not sure if it’s something to do with the codes or not.

Below is the DBAdapter class:

public static final String KEY_ROWID = "_id";
    public static final String KEY_NAME = "name";
    public static final String KEY_DATE = "date";
    public static final String KEY_TYPE = "type";
    public static final String KEY_LIKES = "likes";
    public static final String KEY_DISLIKES = "dislikes";

    private static final String TAG = "InfoDBAdapter";

    private static final String DATABASE_NAME = "friendsDB";
    private static final String DATABASE_TABLE = "friends_info";
    private static final int DATABASE_VERSION = 2;

    private static final String DATABASE_CREATE = "create table friends_info(name_id integer primary key autoincrement, "
            + "name text not null, date text not null, type text not null, likes text not null, dislikes text not null);";

    private final Context context;

    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;

    public InfoDBAdapter(Context ctx)
    {
        this.context = ctx;
        DBHelper = new DatabaseHelper(context);
    }

    private static class DatabaseHelper extends SQLiteOpenHelper
    {
        DatabaseHelper(Context context)
        {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db)
        {
            try
            {
                db.execSQL(DATABASE_CREATE);
            } catch (SQLException e)
            {
                e.printStackTrace();
            }
        }// end onCreate()

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
        {
            Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS friends_info");
            onCreate(db);
        }// end onUpgrade()

    }// end DatabaseHelper

        public InfoDBAdapter open() throws SQLException
        {
            db = DBHelper.getWritableDatabase();
            return this;
        }// end open()

        public void close()
        {
            DBHelper.close();
        }// end close()

        public long insertContact(String name, String date, String type, String likes, String dislikes)
        {
            ContentValues initialValues = new ContentValues();
            initialValues.put(KEY_NAME, name);
            initialValues.put(KEY_DATE, date);
            initialValues.put(KEY_TYPE, type);
            initialValues.put(KEY_LIKES, likes);
            initialValues.put(KEY_DISLIKES, dislikes);
            return db.insert(DATABASE_TABLE, null, initialValues);
        }// end insertContact()

        public boolean deleteContact(long rowId)
        {
            return db.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0;
        }// end deleteContact()

        public Cursor getAllContacts()
        {
            return db.query(DATABASE_TABLE, new String[] 
                    { KEY_ROWID, KEY_NAME, KEY_DATE, KEY_TYPE, KEY_LIKES, KEY_DISLIKES }, null, null, null, null, null);
        }// end getAllContacts()

        public Cursor getContact(long rowId) throws SQLException
        {
            Cursor mCursor = db.query(true, DATABASE_TABLE, new String[] {
                    KEY_ROWID, KEY_NAME, KEY_DATE, KEY_TYPE, KEY_LIKES, KEY_DISLIKES }, KEY_ROWID + "=" + rowId,
                    null, null, null, null, null);
            if (mCursor != null)
            {
                mCursor.moveToFirst();
            }
            return mCursor;
        }// end getContact()

        public boolean updateContact(long rowId, String name, String date, String type, String likes, String dislikes)
        {
            ContentValues args = new ContentValues();
            args.put(KEY_NAME, name);
            args.put(KEY_DATE, date);
            args.put(KEY_TYPE, type);
            args.put(KEY_LIKES, likes);
            args.put(KEY_DISLIKES, dislikes);
            return db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0;
        }// end updateContact()

I appreciate any help provided. Oh and if anyone knows other ways to retrieve data from database and put in spinner I would appreciate the help.
Thanks =)

  • 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-09T04:23:23+00:00Added an answer on June 9, 2026 at 4:23 am

    Looks like you forgot to open your DataBase for operation and your db reference is null and throwing NullPointerException. Try calling following lines-

    infoDB = new InfoDBAdapter(mContext);
    infoDB.open();
    Cursor c = infoDB.getAllContacts();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.