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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:30:45+00:00 2026-05-31T19:30:45+00:00

I am creating a database like this : SQLiteDatabase db = openOrCreateDatabase(mydata.db,SQLiteDatabase.CREATE_IF_NECESSARY,null); try {

  • 0

I am creating a database like this :

SQLiteDatabase db = openOrCreateDatabase("mydata.db",SQLiteDatabase.CREATE_IF_NECESSARY,null);
                    try
                    {
                    db.execSQL("CREATE TABLE IF NOT EXISTS vars (id INTEGER PRIMARY KEY ASC, varname,varvalue);");
                    db.execSQL("INSERT INTO vars (varname,varvalue) VALUES (\"user\",\"" + username + "\");");
                    Log.w("Test", "Am executat sql");

                    }
                    catch (SQLiteException e)
                    {
                        Log.w("Exceptie", "Acum or niciodata");
                    }

When i restart my program and i want to open it like this :

  SQLiteDatabase objDb = null;
        try
        {
            objDb =  SQLiteDatabase.openDatabase("mydata.db", null, SQLiteDatabase.OPEN_READWRITE);

        }
        catch(SQLiteException e)
        {
            //addShortcut();//setShortCut(getApplicationContext(),"GpsRo");
            //setContentView(R.layout.main);
            Log.w("Exceptie", e.getMessage());
            showForm = true;
        }

I get an exception : unable to open database file…

What am i doing wrong ?

  • 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-31T19:30:47+00:00Added an answer on May 31, 2026 at 7:30 pm

    Your database is in the wrong place:
    “mydata.db” means your Databasefile is in root: (Path: /mydata.db). Your App can’t write in the root folder.
    Try context.getFilesDir() + "/mydata.db" instead.

    In one Command:

    SQLiteDatabase db = openOrCreateDatabase(context.getFilesDir()"/mydata.db",SQLiteDatabase.CREATE_IF_NECESSARY,null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an equipment reservation (PHP/MySQL) for my school. My database looks like this:
I'm creating a new database in my Activity like this: @Override public void onCreate(Bundle
I am creating a SQLite database from qt like this: QSqlDatabase db = QSqlDatabase::addDatabase(QSQLITE,
I would like to learn the best practices to employ when creating a database
What program/programming language would be ideal for creating an Access like database on a
I am creating database at runtime and I want to create the tables in
I'm creating a database table and I don't have a logical primary key assigned
I am creating a database in SQL Server 2005 and cannot remember the CREATE
I am creating a SQLite database. To get data from the table I am
I'm creating a social network in Rails and I have a model like 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.