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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:57:27+00:00 2026-06-05T05:57:27+00:00

I am trying to open a writeable SQLite database with this code… public DataAdapterForServieClass

  • 0

I am trying to open a writeable SQLite database with this code…

public DataAdapterForServieClass open() throws SQLException {
    db = DBHelper.getWritableDatabase();
    return this;
}

However I am getting the following error on the db = DBHelper.getWritableDatabase(); line…

06-10 11:58:13.995: ERROR/AndroidRuntime(548): FATAL EXCEPTION: main
06-10 11:58:13.995: ERROR/AndroidRuntime(548): java.lang.StringIndexOutOfBoundsException: index=0 length=0
06-10 11:58:13.995: ERROR/AndroidRuntime(548):     at android.app.ContextImpl.validateFilePath(ContextImpl.java:1518)
06-10 11:58:13.995: ERROR/AndroidRuntime(548):     at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:725)
06-10 11:58:13.995: ERROR/AndroidRuntime(548):     at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
06-10 11:58:13.995: ERROR/AndroidRuntime(548):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:149)

This is the code of my DBHelper class…

static class DatabaseHelper extends SQLiteOpenHelper {
    DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(TAG, "Upgrading database from version " + oldVersion 
            + " to "
            + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS titles");
        onCreate(db);
    }

    public void onCreate(SQLiteDatabase arg0) {
        // TODO Auto-generated method stub
    }
}   

Could someone please help me.

  • 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-05T05:57:30+00:00Added an answer on June 5, 2026 at 5:57 am

    When you call getWritableDatabase() for the first time, it will call the following methods, according to the Android Documentation…

    onCreate(SQLiteDatabase)
    onUpgrade(SQLiteDatabase, int, int)
    onOpen(SQLiteDatabase)
    

    You don’t have any code in your onCreate() method – you’ll need to do something here before it will work, such as this…

    public void onCreate(SQLiteDatabase database) {
        database.openOrCreateDatabase("/come/example/mydatabase",null);
    }
    

    Look at the checkDataBase() method in the link you posted where it calls openDatabase() – this does the same thing, and is the important piece of code that you’re missing. You need to create the database before you can do anything with it.

    Also make sure that somewhere in your code you are creating your DBHelper instance, so that it calls the super() method. Like this…

    DBHelper helper = new DatabaseHelper(context);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to open a pop-up menu from a NSToolbarItem. I tried following this
When trying to open a file using this command: $fd = fopen('majestic_files/majestic_record.txt','w'); I get
I am trying to open a terminal that would execute a code and copy
I'm trying to open MVC project using VS2010 . I'm opening this project from
While trying to open the file in Class in function oninitdialog(),It throws exception.If I
I am trying to open an url through python like this import urllib2 f
This code is for Windows 7. I am trying to grab the response to
im trying to open a url with object c my code is as follows
I´m trying to open a tab using jquery, here is my code: $(#ecContenedorFolders).tabs({ tabTemplate:
I'm trying to open a file for input in Excel with this line :

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.