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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:20:39+00:00 2026-05-25T19:20:39+00:00

I’m a newbie to android development so please bear with me. My question is

  • 0

I’m a newbie to android development so please bear with me. My question is i have an external SQLite file that I want to access through android, what we normally do in iPhone or windows that we simply add the SQlite file as a resource and access it but I’m unable to do the same.
I followed the instruction given here Link but it gives an error “unable to open database file“.

Edited:

09-14 23:31:59.008: INFO/Database(335): sqlite returned: error code = 14, msg = cannot open file at source line 25467
09-14 23:31:59.008: ERROR/Database(335): sqlite3_open_v2("/data/data/com.mobile.socket.server/databases/Database/DictionaryDb.sqlite", &handle, 2, NULL) failed

My DbHelper Class:

package com.dbhandler;

import android.content.ContentValues;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;

public class DbHelper extends SQLiteOpenHelper 
{
    //The Android's default system path of your application database.
    private String DB_PATH = "";//"/data/data/com.mobile.socket.server/databases/";

    private static String DB_NAME = "DictionaryDb.db";

    private SQLiteStatement insertStmt;

    private  SQLiteDatabase myDataBase; 

    /**
     * Constructor
     * Takes and keeps a reference of the passed context in order to access to the application assets and resources.
     * @param context
     */
    public DbHelper(Context context) 
    { 
        super(context, DB_NAME, null, 1);   
        //CreateDatabase(); 
    }   
    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        myDataBase = db;
    }

    private void CreateDatabase()
    {       
        try
        {
            String myPath = DB_PATH + DB_NAME;    
            myDataBase = SQLiteDatabase.openOrCreateDatabase(myPath, null);
            final String CREATE_TABLE_WORDS = "CREATE TABLE WordsTable (WordId INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE , Word TEXT NOT NULL )";
            final String CREATE_TABLE_MEANINGS = "CREATE TABLE MeaningTable (MeaningId INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL , WordId INTEGER NOT NULL , Meaning TEXT NOT NULL )";
            myDataBase.execSQL(CREATE_TABLE_WORDS);
            myDataBase.execSQL(CREATE_TABLE_MEANINGS);
        }
        catch (Exception e) 
        {
            e.fillInStackTrace();
        }
    }

    public boolean AddNewWord(String word)
    {
        CreateDatabase();
        String myPath = DB_PATH + DB_NAME;      
        //ContentValues newRecord = new ContentValues();
        boolean RetVal = false;
        try
        {
            final String INSERT = "Insert into WordsTable(Word)  Values('"+word+"')";
            myDataBase = myDataBase.openDatabase(DB_NAME, null,SQLiteDatabase.OPEN_READWRITE);
            insertStmt = myDataBase.compileStatement(INSERT);
        //  myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);
            //newRecord.put("Wordstable", word);
            //long newWordid = myDataBase.insert("Wordstable", null, newRecord);
        }
        catch (SQLException  e) 
        {
            e.fillInStackTrace();
        }
        return RetVal;
    }
    @Override
    public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
        // TODO Auto-generated method stub

    }

}
  • 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-25T19:20:39+00:00Added an answer on May 25, 2026 at 7:20 pm

    I was able to figure this out myself, OnCreate function of SqLiteHelper was not getting called so in the class constructor I called this.getWritableDatabase() this forced “OnCreate” function that created my database object I was able to get my work done.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
i want to parse a xhtml file and display in UITableView. what is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.