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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:51:42+00:00 2026-05-23T08:51:42+00:00

I am trying to open a SQLite database in android, the database works fine

  • 0

I am trying to open a SQLite database in android, the database works fine in the sqlite browser, but android does not read that the table in question exists. Below is the code I’m tinkering with.

public String setColorName() {
    String colorName = null;
    try {
        db = this.openOrCreateDatabase("colors.db",MODE_WORLD_READABLE, null); 
        Cursor cursor = db.rawQuery("SELECT colorName FROM Colors WHERE RGB = '000000'", null);
        if (cursor != null) {
            if (cursor.moveToFirst()){
                do {
                    colorName = cursor.getString(cursor.getColumnIndex("colorName"));
                }while (cursor.moveToNext());
            }
        } else {
            colorName = "woops";
        }
    } catch (NumberFormatException e) {}

    return colorName ;
}

I have found many articles regarding this issue on several forums (including stackoverflow) but the
issue I’m having didn’t seem to get resolved with their solutions. I’m trying to pull the RGB and colorname from the code (the query above is just a test leading up to that) so that I can estimate the nearest RGB using the euclidean distance formula on each portion. In order to do that, I need to be able to atleast grab the data from the table :P.

LogCat:

    I/Database(12748): sqlite returned: error code = 1, msg = no such table: Colors
D/AndroidRuntime(12748): Shutting down VM
W/dalvikvm(12748): threadid=1: thread exiting with uncaught exception (group=0x4
0015560)
E/AndroidRuntime(12748): FATAL EXCEPTION: main
E/AndroidRuntime(12748): android.database.sqlite.SQLiteException: no such table:
 Colors: , while compiling: SELECT colorName FROM Colors WHERE RGB = '000000'
E/AndroidRuntime(12748):        at android.database.sqlite.SQLiteCompiledSql.nat
ive_compile(Native Method)
E/AndroidRuntime(12748):        at android.database.sqlite.SQLiteCompiledSql.com
pile(SQLiteCompiledSql.java:92)
E/AndroidRuntime(12748):        at android.database.sqlite.SQLiteCompiledSql.<in
it>(SQLiteCompiledSql.java:65)
E/AndroidRuntime(12748):        at android.database.sqlite.SQLiteProgram.<init>(
SQLiteProgram.java:83)
E/AndroidRuntime(12748):        at android.database.sqlite.SQLiteQuery.<init>(SQ
LiteQuery.java:49)
E/AndroidRuntime(12748):        at android.database.sqlite.SQLiteDirectCursorDri
ver.query(SQLiteDirectCursorDriver.java:42)
E/AndroidRuntime(12748):        at android.database.sqlite.SQLiteDatabase.rawQue
ryWithFactory(SQLiteDatabase.java:1356)
E/AndroidRuntime(12748):        at android.database.sqlite.SQLiteDatabase.rawQue
ry(SQLiteDatabase.java:1324)

And finally, here’s a picture of the SQLite browser showing that the query does work on that database
SQLiteBrowser Query

Incase the picture didn’t give it away, I’m storing the colors.db in assets.

Sorry for the length, I try to be as thorough as possible and seriously appreciate anyone who helps me.

Ok, it looks like I got past the issue. I needed to copy the db from assets and then open it from there. I ended up making a database helper using the information I found in the link below and I got the database to stop returning that error, though I now need to complete the rest of the application. Thanks a ton for all the great advise, everyone! http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

  • 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-23T08:51:43+00:00Added an answer on May 23, 2026 at 8:51 am

    You are creating the database and after that you wish to access the table from it. Don’t you need to create the tables too? I’d suggest you to use SQLiteOpenHelper instead of openOrCreateDatabase so you won’t run into this problem.
    If you wanna access an existing database through assets (as I’ve seen on your screenshot), you could refer to SQLiteException: no such table

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

Sidebar

Related Questions

I'm developing an iPhone app that uses the built-in SQLite database. I'm trying to
Is this possible? I am trying to open a SQLite database cursor in one
i am trying to open ABPersonViewController at table delegate method (DidSelectRowAtIndex). but when i
I am (re)writing an android app that uses an SQLite database to store various
I'm trying to open a file and create a list with each line read
I'm trying to open and read from a serial port using the System.IO.Ports.SerialPort class.
I'm trying to locate an open source business rules engine that has a decent
I guess many people already read this article: Using your own SQLite database in
I am trying to retrieve a password from an SQLite database. The id of
I am having problems connecting to a Sqlite database through System.Data.Sqlite. I was trying

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.