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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:21:20+00:00 2026-05-25T19:21:20+00:00

I am having difficulty opening my database in my class. I am trying to

  • 0

I am having difficulty opening my database in my class. I am trying to get my application to start on the phone bootup, that is only if the boolean value in the database is true, if false it will not boot the application on startup. I have the errors to the bottom

public class My_BroadcastReceiver extends BroadcastReceiver {   

SQLiteDatabase sqlDB;
private static String DBNAME2 = "database2.db";
private static String Table2 = "options";

Boolean isOk = true;
Context context;

@Override  
public void onReceive(Context context, Intent intent) {


    try {

        sqlDB = SQLiteDatabase.openOrCreateDatabase(DBNAME2, null);

        Cursor r = sqlDB.rawQuery("SELECT Apponstart FROM " + Table2, null);
        System.out.println("COUNT of Location: " + r.getCount());
        int loc = r.getColumnIndex("Apponstart");

        int j = 0;
        if (r.moveToFirst()) {
            do {
                System.out.println("Apponstart is " + r.getString(loc));

                isOk = Boolean.parseBoolean(r.getString(loc));

                j++;
            } while (r.moveToNext());
            if (j == 0) {
                System.out.println("No data found");
            }

        }
        r.close();
        // sqlDB.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        sqlDB.close();
    }

    if(isOk){
        Intent i = new Intent(context, JoshTwoActivity.class);                   
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                
        context.startActivity(i); 
    }
}



 09-23 08:10:05.615: WARN/System.err(208): android.database.sqlite.SQLiteException: unable to open database file
        09-23 08:10:05.625: WARN/System.err(208):     at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
        09-23 08:10:05.625: WARN/System.err(208):     at                android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1812)
        09-23 08:10:05.625: WARN/System.err(208):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:817)
        09-23 08:10:05.625: WARN/System.err(208):     at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:851)
        09-23 08:10:05.625: WARN/System.err(208):     at three.three.My_BroadcastReceiver.onReceive(My_BroadcastReceiver.java:31)
         09-23 08:10:05.625: WARN/System.err(208):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
         09-23 08:10:05.625: WARN/System.err(208):     at android.app.ActivityThread.access$3200(ActivityThread.java:125)
           09-23 08:10:05.625: WARN/System.err(208):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
          09-23 08:10:05.625: WARN/System.err(208):     at android.os.Handler.dispatchMessage(Handler.java:99)
            09-23 08:10:05.625: WARN/System.err(208):     at android.os.Looper.loop(Looper.java:123)
          09-23 08:10:05.625: WARN/System.err(208):     at android.app.ActivityThread.main(ActivityThread.java:4627)
          09-23 08:10:05.625: WARN/System.err(208):     at java.lang.reflect.Method.invokeNative(Native Method)
          09-23 08:10:05.625: WARN/System.err(208):     at java.lang.reflect.Method.invoke(Method.java:521)
         09-23 08:10:05.625: WARN/System.err(208):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
         09-23 08:10:05.625: WARN/System.err(208):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
         09-23 08:10:05.625: WARN/System.err(208):     at dalvik.system.NativeStart.main(Native Method)

And again at

       09-23 08:10:06.046: ERROR/AndroidRuntime(208): FATAL EXCEPTION: main
       09-23 08:10:06.046: ERROR/AndroidRuntime(208): java.lang.RuntimeException:  Unable to start receiver three.three.My_BroadcastReceiver: java.lang.NullPointerException
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at android.app.ActivityThread.access$3200(ActivityThread.java:125)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at android.os.Handler.dispatchMessage(Handler.java:99)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at android.os.Looper.loop(Looper.java:123)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at android.app.ActivityThread.main(ActivityThread.java:4627)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at java.lang.reflect.Method.invokeNative(Native Method)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at java.lang.reflect.Method.invoke(Method.java:521)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at dalvik.system.NativeStart.main(Native Method)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208): Caused by: java.lang.NullPointerException
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at three.three.My_BroadcastReceiver.onReceive(My_BroadcastReceiver.java:57)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
       09-23 08:10:06.046: ERROR/AndroidRuntime(208):     ... 10 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-25T19:21:21+00:00Added an answer on May 25, 2026 at 7:21 pm

    The database was the problem. I created a method and added context to the opening of the database. Here is my solution.

    public void guru(Context ctx){
    
        System.out.println("Flax");
        try {
            Log.e("troll", "alol");
            sqlDB = ctx.openOrCreateDatabase(DBNAME2, 0,null); 
            //sqlDB = SQLiteDatabase.openOrCreateDatabase(DBNAME2, null);           
            Cursor r = sqlDB.rawQuery("SELECT Apponstart FROM " + Table2, null);
            System.out.println("COUNT of Location: " + r.getCount());
            int loc = r.getColumnIndex("Apponstart");
    
            int j = 0;
            if (r.moveToFirst()) {
                do {
                    System.out.println("Apponstart is " + r.getString(loc));
                    Log.d("happening", "here");
                    isOk = Boolean.parseBoolean(r.getString(loc));
    
                    j++;
                } while (r.moveToNext());
                if (j == 0) {
                    System.out.println("No data found");
                }
    
            }
            r.close();
            // sqlDB.close();
        } catch (Exception e) {
            e.printStackTrace();
            Log.e("exception", e.toString());
        } finally {
            sqlDB.close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having difficulty using MooseX::Declare properly when calling BUILDARGS. I'm trying to create an
I am having difficulty connecting my java code to sql server database. I can
I am having difficulty opening a EXCEL 2007 in Delphi 7 It works for
I'm having difficulty extracting a single node value from a nodelist. My code takes
I'm having difficulty setting up a simple menu that displays results on a div
I'm having difficulty figuring out how to write a module with a form that
I'm having difficulty testing some logic that uses notifications. I've read about enforcing that
I'm having difficulty writing a trigger that sets the rank column to the max
I'm having difficulty getting the binding to fire off on a user control that
Having difficulty checking (checkbox) all nodes by a specific class here is what i

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.