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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:36:11+00:00 2026-06-14T03:36:11+00:00

i want to create a SQLLite Database with openOrCreateDatabase. The problem is, that i

  • 0

i want to create a SQLLite Database with “openOrCreateDatabase”. The problem is, that i get an error while creating a new table.

11-11 12:36:39.865: E/AndroidRuntime(1520): java.lang.IllegalStateException: 
database not open

This is my code:


public class MainActivity extends Activity {

EditText playerName;
Button submitPlayer;
SQLiteDatabase myDB = null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    playerName = (EditText)findViewById(R.id.playerName);
    submitPlayer = (Button)findViewById(R.id.submitPlayer);


        myDB = SQLiteDatabase.openOrCreateDatabase("/data/data/com.my.appname/mydb.db",null);           
  try{          

        myDB.execSQL("CREATE TABLE IF NOT EXISTS player (playername VARCHAR)");         
        myDB.execSQL("INSERT INTO player VALUES('test')");

...
..

I added 2 lines in the manifest:

< permission-group android:name=”android.permission-group.STORAGE”>

< uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />

Whats wrong ?

Thanks a lot !

  • 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-14T03:36:12+00:00Added an answer on June 14, 2026 at 3:36 am

    You shouldn’t be accessing your database like this. And also you don’t need storage permissions for /data/data, that’s for sdcard.
    What you should be doing is using SQLiteOpenHelper to manage your db. Here’s a tutorial to get you started

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

Sidebar

Related Questions

I have problem with sqlite database. I want create database in android with existing
I want to create an android application which get data from sqlite database placed
In my application I have a sqlite database that looks like this: CREATE TABLE
I am new to android. I would like to create a database that will
I want to create a table in a SQLite database only if doesn't exist
I am working on Mac OS X, I want to create a new SQLite
Im new to android and I want to create kind of CRUD with SQLite.
I want create wordpress website into which I want create user management... That means
i want create a custom json data from the mssql 2008 results so that
I want to get data from my Sqlite database and put it into this

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.