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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:46:43+00:00 2026-06-12T16:46:43+00:00

First up, I am new to android apps and am not working solo on

  • 0

First up, I am new to android apps and am not working solo on this. My team mate has taken design while I handle this, and asked me to set up the database and the method to do this, etc etc.

So while most of this seems to be ok, I put:

Context context = null;
DataBaseHelper drinksDataBase = new DataBaseHelper(context); 

into his main activity.

The constructer is as follows:

public DataBaseHelper(Context  context) {

    super(context, DB_NAME, null, 1);
    this.myContext = context;
    try{
        createDataBase();
    }
    catch(IOException e){

    }
}

Ignoring the null, which I am assuming is the current cause of the app crashing, how would I go about getting the proper context for the app so that I can make my database work?

It actually seems to be crashing on this.getReadableDatabase() so whether that is the null context or not, I don’t know.

Logcat is failing to launch due to:

[2012-10-12 10:37:57 - Unexpected error while launching logcat. Try reselecting the device.] device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
    at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:752)
    at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:373)
    at com.android.ddmlib.Device.executeShellCommand(Device.java:462)
    at com.android.ddmuilib.logcat.LogCatReceiver$1.run(LogCatReceiver.java:109)
    at java.lang.Thread.run(Unknown Source)  

Thanks in advance,

James

  • 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-12T16:46:44+00:00Added an answer on June 12, 2026 at 4:46 pm

    If you’re using eclipse it’s beyond child’s play. Just make a field somewhere “private Context context” then you go to generate constructor from fields in the source tab. Just spits it out for you. Then when you need to make an instance of the class. Usually “this” in parameters will suffice

    EDIT


    I hope this helps, I’d rather not prolong a discussion here.
    in your database:

    public DataBaseHelper(Context  context) {
        super(context, DB_NAME, null, 1);
    }
    
    public Cursor getDrinks() {
            SQLiteDatabase db = getReadableDatabase();
            Cursor cursor = db.query(DB_NAME, null, null, null, null, null, null);
            return cursor;
        }
    

    Then in your activity (in oncreate):

    private Cursor c;
    
    ...
    DataBaseHelper drinksDataBase = new DataBaseHelper(this);
    c = drinksDataBase.getDrinks(); 
    c.moveToFirst();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to start making cellphone apps with Android as first choice but not
I was reading the new Android Design Standards here: http://developer.android.com/design/patterns/selection.html and was wondering first
I'll preface this with I'm really new to working on Android. So I have
First of all, I know this has been asked before: Button in custom Android
I am new to android. I got one issue during run my first hello
First of all, I'm quite new to the Android and JAVA world (coming from
I'm building my first Android image, i noticed that compiling a new kernel is
Consider a string array shaped like this: string[] someName = new string[] { First,
First of all i'm new in here and new with csharp. just exhausted while
I have just started working on my first Android application and am going ok.

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.