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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:13:39+00:00 2026-05-26T02:13:39+00:00

I was working with one table and all my program is ok, but now

  • 0

I was working with one table and all my program is ok, but now I have to add another table to my database, and by logic this is the code :

package net.ShamanOperativo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class UsuariosSQLiteHelper extends SQLiteOpenHelper {

    //Sentencia SQL para crear la tabla de Incidentes
    String sqlCreate = "CREATE TABLE Incidentes  ( idInterno INTEGER PRIMARY KEY  , codReg TEXT, codGr TEXT, entidad TEXT, codInc TEXT, loc TEXT, dom TEXT, sint TEXT, movil TEXT, sexo TEXT, edad INTEGER, estado TEXT, latitud DOUBLE, longitud DOUBLE,colorLoc TEXT, colorGr TEXT )";
    String sqlCreate2 = "CREATE TABLE Moviles (idInterno INTEGER PRIMARY KEY, numMovil TEXT, colMovil TEXT, estado TEXT, localidad TEXT, cantServ INTEGER)";
    String sqlCreateIndex = "CREATE UNIQUE INDEX idxIdInterno ON Incidentes(idInterno)";

    public UsuariosSQLiteHelper(Context contexto, String nombre,
                               CursorFactory factory, int version) {
        super(contexto, nombre, factory, version);


    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //Se ejecuta la sentencia SQL de creación de la tabla
        db.execSQL(sqlCreate);
        db.execSQL(sqlCreateIndex);
        db.execSQL(sqlCreate2);




    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int versionAnterior, int versionNueva) {

        //Se elimina la versión anterior de la tabla
        db.execSQL("DROP TABLE IF EXISTS Incidentes");
        db.execSQL("DROP TABLE IF EXISTS Moviles");


        //Se crea la nueva versión de la tabla
        db.execSQL(sqlCreate);
        db.execSQL(sqlCreate2);

    }
}

My table Incidentes is ok, it is which I was using always.. but I can’t use the table Moviles, I use my table here:

 UsuariosSQLiteHelper usdbh =
                new UsuariosSQLiteHelper(this, "DBIncidentes", null, 1);

            SQLiteDatabase db = usdbh.getWritableDatabase();         //Abro base de datos para escritura

            if(db != null)
            {

                 //db.execSQL("DELETE from Moviles");
                 for (int i=0; i<= (vecTotal.length) -1; i++) {



                String reg = vecTotal[i].toString(); 
                String [] inc = TextUtils.split(reg, "\\^");




                String numMovil = inc[0];
                String colMovil = inc[1];
                String estado = inc[2];
                String localidad = inc[3];
                String strCantServ = inc[4];

                Integer cantServ = Integer.parseInt(strCantServ);



                try{                

                    //Insertamos los datos en la tabla Incidentes
 db.execSQL("INSERT INTO Moviles ( idInterno, numMovil, colMovil, estado, localidad, cantServ) " +
             "VALUES ("+(i+1)+", '" + numMovil +"', '" + colMovil +"' , '" + estado +"', '" + localidad +"', " +cantServ +" )");



}

catch (Exception e)

{
    e.getMessage();


}

Is there another thing I have to do to handle two tables or more? It isn’t the same adapter and just refering which table of the database I want to consult or add info?

When the program want to add info into Moviles, logcat says it can’t because Moviles doesn’t exist.

  • 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-26T02:13:40+00:00Added an answer on May 26, 2026 at 2:13 am

    No, there isn’t anything extra you need to do for handling more than 1 table.

    I think your table is not created because neither onCreate() (because your database already exists) noronUpdate() (you never increased the database version you pass to the UsuariosSQLiteHelper, right?) is called.

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

Sidebar

Related Questions

I'm attempting to delete all rows in one table that do not have a
Hey all, got one mountain of a problem here. I have completed a program
I have one table that has an Id (PK) and another table with a
I'm inserting multiple rows from one table to another, based on ID. For this
I am working in one real-estate website and I have large database around 250
I am working on one document system and got some logic/architectual problems. In this
I have two tables in this project of mine. One table is for the
I'm Working with a new Oracle DB, with one table having the following indexes:
Right now I am working on one Real Estate Website, In that website I
I'm working on a program to store and manage test results. Tests have properties

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.