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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:22:14+00:00 2026-05-26T06:22:14+00:00

I have some simple code which should create a database. package com.webfoo.android.databaseExample; import android.app.Activity;

  • 0

I have some simple code which should create a database.

package com.webfoo.android.databaseExample;

import android.app.Activity;
import android.os.Bundle;

public class DatabaseExampleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        jokesHelper db = new jokesHelper(getBaseContext());
    }
}

package com.webfoo.android.databaseExample;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class jokesHelper extends SQLiteOpenHelper {

    private static final String DATABASE_NAME = "test.db";
    private static final int DB_VERSION = 1;

    public jokesHelper(Context context) {
        super(context, DATABASE_NAME, null, DB_VERSION);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL("create table todo (_id integer primary key autoincrement, "
                 + "joke text not null, punch text not null);");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub

    }

}

does any have any idea why this fails to create a database? My phone is connected to my machine and the SD isn’t mounted, but it’s on debug mode (i can see my add being ran on my phone).

I haven’t modified the manifest either, so could that be causing any issues?

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-05-26T06:22:15+00:00Added an answer on May 26, 2026 at 6:22 am

    You haven’t called getWritableDatabase() or getReadableDatabase() yet.

    e.g.

    jokesHelper dbHelper = new jokesHelper(getBaseContext());
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    

    The databases are not stored on the SD card or otherwise USB-mountable storage (at least not by default). They are in “internal” storage. The path in your comment above is almost right, but I’m not sure what “DATA” means. The path is: /data/data/<package name>/databases. You can check that by using adb shell ls /data/data/<package name>/databases.

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

Sidebar

Related Questions

I have some code I've written in PHP for consuming our simple webservice, which
I have some very simple code to generate an assembly and invoke a method
I have some VERY simple code to return the title for a section header:
Currently, I have some basic code to play a simple tone whenever a button
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have a fairly simple const struct in some C code that simply holds
Question simple and quick: I have started to use Netbeans to write some code
I have some simple XML which I would like to parse into an array
So I have some animation blocks to create some very simple animations on my
Does anyone have some sample code showing how to POST to a URL using

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.