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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:15:42+00:00 2026-06-16T17:15:42+00:00

Good morning every body; I’m trying to make a database class in android, and

  • 0

Good morning every body;

I’m trying to make a database class in android, and it is done, I’ve created a table successfully too. The problem comes when I want to insert rows to the table using ContentValues, it tries to insert the row in different order from the table fields which cuases an error in the logcat saying : no such table as follows:

These are my variables:

    private static final String row_ID="RID";
    private static final String row_NAME="NAME";
    private static final String row_EMAIL="EMAIL";
    private static final String row_WEBSITE="WEBSITE";
    private static final String row_TELEPHONE1="PHONE_NUMBER1";
    private static final String row_TELEPHONE2="PHONE_NUMBER2";
    private static final String row_TELEPHONE3="PHONE_NUMBER3";
    private static final String row_TELEPHONE4="PHONE_NUMBER4";
    private static final String row_TELEPHONE5="PHONE_NUMBER5";
    private static final String db_NAME="ContactsDb";
    private static final String tab_NAME="ContactsTab";
    private static final int db_VERSION=2;
    private dbHelper ourHelper;
    private final Context ourContext;
    private SQLiteDatabase ourDatabase;

My table :

    String CREATE_TABLE="CREATE TABLE " + db_NAME + " ("
                            + row_ID + " INT PRIMARY KEY AUTOINCREMENT,"
                            + row_NAME + " TEXT, "
                            + row_EMAIL + " TEXT, "
                            + row_WEBSITE + " TEXT, "
                            + row_TELEPHONE1 + " TEXT, "
                            + row_TELEPHONE2 + " TEXT, "
                            + row_TELEPHONE3 + " TEXT, "
                            + row_TELEPHONE4 + " TEXT, "
                            + row_TELEPHONE5 + " TEXT);";
        db_name.execSQL(CREATE_TABLE);

Inserting rows using ContentValues :

    public long createEntry(String name, String email, String website, String telephone1, String telephone2, String telephone3, String telephone4, String telephone5)
{
    ContentValues cv = new ContentValues ();

    Log.v("STATUS", "getting input data..");

    cv.put(row_NAME, name);
    cv.put(row_EMAIL, email);
    cv.put(row_WEBSITE, website);       
    cv.put(row_TELEPHONE1, telephone1);
    cv.put(row_TELEPHONE2, telephone2);
    cv.put(row_TELEPHONE3, telephone3);
    cv.put(row_TELEPHONE4, telephone4);
    cv.put(row_TELEPHONE5, telephone5);
    Log.v("STATUS", "got input data, inserting data....");

    return ourDatabase.insert(tab_NAME, null, cv);
}

So, when I run this application it succeeds doing all these until it arrives to ourDatabase.insert(tab_NAME, null, cv); it shows the error:

    SQLiteLog            (1) no such table: ContactsTab
    SQLiteDatabase       Error inserting Name=Ahlam M. Hussain   PHONE_NUMBER5=
                         PHONE_NUMBER4=   PHONE_NUMBER3=    PHONE_NUMBER2=059999999
                         PHONE_NUMBER1= 09299999    EMAIL=ahlam@ahlam.com    EWEBSITE=
    SQLiteDatabase       android.database.sqlite.SQLiteException: no such table:
                         ContactsTab (code 1): ,while compiling: INSERT INTO
                         ContactsTab(NAME, PHONE_NUMBER5 PHONE_NUMBER4 PHONE_NUMBER3
                         PHONE_NUMBER2 PHONE_NUMBER1, EMAIL, WEBSITE) VALUES
                         (?,?,?,?,?,?,?,?)

You can notice that it is trying to insert row in different fields orderm so it is not recognizing the table..

So what to do ??? I really got suck of that..

  • 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-16T17:15:44+00:00Added an answer on June 16, 2026 at 5:15 pm

    You forget to set brace on

    • row_TELEPHONE5 + ” TEXT;”;

    it has to be

    • row_TELEPHONE5 + ” TEXT);”;

    EDIT

    try it with “CREATE TABLE IF NOT EXISTS” and “INTEGER PRIMARY KEY AUTOINCREMENT” not “INT PRIMARY KEY AUTOINCREMENT”. Also You had set db_name instead of table_name in your CREATE-TABLE String. Change it to your table_name:

         String CREATE_TABLE="CREATE TABLE IF NOT EXISTS " + tab_NAME + " ("
                            + row_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
                            + row_NAME + " TEXT, "
                            + row_EMAIL + " TEXT, "
                            + row_WEBSITE + " TEXT, "
                            + row_TELEPHONE1 + " TEXT, "
                            + row_TELEPHONE2 + " TEXT, "
                            + row_TELEPHONE3 + " TEXT, "
                            + row_TELEPHONE4 + " TEXT, "
                            + row_TELEPHONE5 + " TEXT);";
        db_name.execSQL(CREATE_TABLE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning, I've successfully created a little app that registers itself under a custom
So, I'd like to be able to make a call x = MyClass.new('good morning',
Good morning, I've been up all night trying to figure this out on my
Good morning all. I'm having a small crisis with table views in a 3.1
Good Morning every one. I need a web page to load completely and then
Good Morning! Given: public class FooClass { public void FooMethod() { using (var myEntity
Good Morning, I have a SharePoint site that I've been trying to fix up
Good morning, I finally managed to store the Facebook usernames in my database after
Good Morning, I am trying to call the same function everytime the user presses
Good morning! I'm writing a class for drawing histograms and, for user's convenience, I've

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.