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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:04:18+00:00 2026-06-02T06:04:18+00:00

I am trying to create more than one table in the database but the

  • 0

I am trying to create more than one table in the database but the first table is only created successfully and the two others gives me errors i want to know how to make sure that the tables are created

04-18 17:20:45.343: E/AndroidRuntime(956): android.database.sqlite.SQLiteException: no such table: squares: , while compiling: SELECT _squareid, squarename, squarelatitude, squarelongitude FROM squares

here it is my code

public class Dbinfo {

    public static final String KEY_RAWID = "_id";
    public static final String KEY_RAWNAME = "name";
    public static final String KEY_PASSWORD = "password";
    public static final String KEY_EMAIL = "email";
    public static final String KEY_SQUAREID = "_squareid";
    public static final String KEY_SQUARENAME = "squarename";
    public static final String KEY_SQUARELATITUDE = "squarelatitude";
    public static final String KEY_SQUARELONGITUDE = "squarelongitude";
    private static final String KEY_STREETID = "streetid";
    private static final String KEY_STREETNAME = "streetname";
    private static final String KEY_STREETLATITUDE="streetlatitude";
    private static final String KEY_STREETLONGTIUDE="streetlongtiude";
    private static final String KEY_STREETCAPACITY = "streetcapacity";
    private static final String KEY_STREETFOREIGN = "streetforegin";

    private static final String DATABASE_NAME = "users_DB";
    private static final String DATABASE_TABLE = "users";
    private static final String DATABASE_TABLESQUARES = "squares";
    private static final String DATABASE_TABLE_STREETS = "streets";
    private static final int DATABASE_VERSION = 1;

    private dbusers ourhelper;
    private final Context ourcontext;
    private static SQLiteDatabase ourDatabase;

    private static class dbusers extends SQLiteOpenHelper {

        public dbusers(Context context) {
            super(context, DATABASE_TABLE, null, DATABASE_VERSION);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub

            db.execSQL("CREATE TABLE " + DATABASE_TABLE + "(" + KEY_RAWID
                    + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_RAWNAME
                    + " TEXT NOT NULL, " + KEY_PASSWORD + " TEXT NOT NULL, "
                    + KEY_EMAIL + " TEXT NOT NULL);");

            db.execSQL("CREATE TABLE " + DATABASE_TABLESQUARES + "("
                    + KEY_SQUAREID + "INTEGER PRIMARY KEY AUTOINCREMENT, "
                    + KEY_SQUARENAME + "TEXT NOT NULL, " + KEY_SQUARELATITUDE
                    + "TEXT NOT NULL, " + KEY_SQUARELONGITUDE
                    + "TEXT NOT NULL);");

            final String STREET = "CREATE TABLE " + DATABASE_TABLE_STREETS
                    + " (" + KEY_STREETID
                    + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_STREETNAME+
                    " TEXT NOT NULL"+KEY_STREETLATITUDE+"TEXT NOT NULL"+KEY_SQUARELONGITUDE
                    + " TEXT NOT NULL, " + KEY_STREETCAPACITY
                    + " text not null, FOREIGN KEY (" + KEY_STREETFOREIGN
                    + ") REFERENCES " + DATABASE_TABLESQUARES + " ("
                    + KEY_SQUAREID + "));";
            db.execSQL(STREET);

Any help??

  • 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-02T06:04:20+00:00Added an answer on June 2, 2026 at 6:04 am

    Put some spaces after your column names in your sql creation String(for the table DATABASE_TABLESQUARES):

    db.execSQL("CREATE TABLE " + DATABASE_TABLESQUARES + "("
                        + KEY_SQUAREID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
                        + KEY_SQUARENAME + " TEXT NOT NULL, " + KEY_SQUARELATITUDE
                        + " TEXT NOT NULL, " + KEY_SQUARELONGITUDE
                        + " TEXT NOT NULL);");
    

    After you make the above modifications you’ll have to uninstall the app and re run it so the onCreate method of the SQLiteOpenHelper will be called again to initialize a database according to the new sql String.
    Also, as Sam’s comment, also modify the sql creation String for the table DATABASE_TABLE_STREETS and add some commas between the column declaration(like you previously did for the other two tables) or will get in trouble again when you try to access that table.

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

Sidebar

Related Questions

I can't create more than one table on a Chrome App dadabase Here is
Im trying to create a server/client application that will work on two or more
On our live/production database I'm trying to add a trigger to a table, but
I have ran into an interesting issue while trying to create a more usable
I'm trying to create a sample RPC program to learn more about it. What
Trying to create a user account in a test. But getting a Object reference
Trying to create my first iPhone app that would play back audio. When I
I am trying to create a jquery plugin to do ajax table pagination (i.e
I'm trying to create a procedure that would return a table with 'child numbers'
I'm trying to understand if it's right to use one table for votes for

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.