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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:49:49+00:00 2026-05-27T15:49:49+00:00

I have Created a database in Sqllite Android Application and I tried to add

  • 0

I have Created a database in Sqllite Android Application and I tried to add two tables in my Database, but I have problem to create that Database. First Table only Created. Can anyBody help me?

    package com.android.cdtech;

    import java.sql.SQLException;

    import android.content.ContentValues;
  import android.content.Context;
import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.util.Log;

  public class saveData {
 public static final String KEY_ROWID = "rowid"; public static final String KEY_DATE = "Date";public static final String KEY_NAME = "CustomerName";public static final String KEY_AMOUNT = "Amount";public static final String KEY_BANK = "Banks";
 private static final String TAG = "DBAdapter";
 public static final String KEY_BUSNAME="BusinessName";public static final String KEY_ADD="Address";public static final String KEY_CPERSON="ContactPerson";;
 private static final String DATABASE_NAME = "EXPORTDETAILS";
 private static final String DATABASE_TABLE = "Payment";
 private static final String DATABASE_TABLE2 = "Customer";
 private static final int DATABASE_VERSION = 1;
 private static  String DATABASE_CREATE =
"create table Payment (_id integer primary key autoincrement, "
+ "Date text not null,"+"CustomerName text not null,"+"Amount text not null,"+"Banks text not null);";  

 private static final String DATABASE_CREATECUS =
            "create table Customer (_id integer primary key autoincrement, "
            + "BusinessName text not null,"+"Address text not null,"+"ContactPerson text not null,"+"PhoneNumber text not null,);";
 private final Context context;  
 private DatabaseHelper DBHelper;
 private SQLiteDatabase db;



    public saveData(Context ctx) 
    {
        this.context = ctx;
        DBHelper = new DatabaseHelper(context);
    }
    private static class DatabaseHelper extends SQLiteOpenHelper 
    {
        DatabaseHelper(Context context) 
        {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) 
        {
            db.execSQL(DATABASE_CREATE);
            db.execSQL(DATABASE_CREATECUS);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, 
                              int newVersion) 
        {
            Log.w(TAG, "Upgrading database from version " + oldVersion 
                  + " to "
                  + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS titles");
            onCreate(db);
        }
    }    
public saveData open()throws SQLException
{
    db=DBHelper.getWritableDatabase();
    return this;
}
public void close()
{
    DBHelper.close();
}

    public long insert(String Date,String CustomerName,String Amount,String Banks) {
    // TODO Auto-generated method stub
     ContentValues cv=new ContentValues();
     cv.put(KEY_DATE,Date);
     cv.put(KEY_NAME,CustomerName);
     cv.put(KEY_AMOUNT,Amount);
     cv.put(KEY_BANK,Banks);
     return db.insert(DATABASE_TABLE, null,cv);
}   
    public long insertForm(String BusinessName ,String Address ,String ContactPerson) {
        // TODO Auto-generated method stub
         ContentValues cv=new ContentValues();
         cv.put(KEY_BUSNAME,BusinessName);
         cv.put(KEY_ADD,Address);
         cv.put(KEY_CPERSON,ContactPerson);
    }
    public Cursor getlatlng()
     {
        Cursor latlngCursor = db.rawQuery("select * from " + DATABASE_TABLE,null);
         if (latlngCursor != null) 
         {
             latlngCursor.moveToFirst();
         }
         db.close();
        return latlngCursor;
     }
    public Cursor order()
     {
        Cursor latlngCursor = db.rawQuery("select * from " + DATABASE_TABLE2,null);
         if (latlngCursor != null) 
         {
             latlngCursor.moveToFirst();
         }
         db.close();
        return latlngCursor;
     }
}

Error Code =1 No Such table for Customer

  • 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-27T15:49:49+00:00Added an answer on May 27, 2026 at 3:49 pm
    use below two class
    
    package Your 'packagename';
    
    
    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.util.Log;
    
    
    public class DBHelper extends SQLiteOpenHelper {
        private static final String DATABASE_NAME = "BistroDB";
    
        private static final int DATABASE_VERSION =1;
    
        // Database creation sql statement
        public static final String Table1= "create table table1name ("Your cloumns");";
    
    
        public static final String Table2 = "create table table2name ("Your cloumns");";
    
    
    
    
        public DBHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }
    
        // Method is called during creation of the database
        @Override
        public void onCreate(SQLiteDatabase database) {
            database.execSQL(table1);
           database.execSQL(table2);
    
        }
    
        // Method is called during an upgrade of the database, e.g. if you increase
        // the database version
        @Override
        public void onUpgrade(SQLiteDatabase database, int oldVersion,
                int newVersion) {
            Log.w(DBHelper.class.getName(),
                    "Upgrading database from version " + oldVersion + " to "
                            + newVersion + ", which will destroy all old data");
            database.execSQL("DROP TABLE IF EXISTS table1");
            database.execSQL("DROP TABLE IF EXISTS table2");
    
            onCreate(database);
        }
    
    
            public boolean deleteDatabase(Context context) {
                return context.deleteDatabase(DATABASE_NAME);
            }
    
    }
    

    Use below class to insert values into table

      package 'Your package name';
    
    
    
        import android.content.ContentValues;
        import android.content.Context;
        import android.database.Cursor;
        import android.database.SQLException;
        import android.database.sqlite.SQLiteDatabase;
    
        public class DataBaseAdapter {
    
            // Database fields
    
            private Context context;
            private SQLiteDatabase database;
            private DBHelper dbHelper;
    
            public DataBaseAdapter(Context context) {
                this.context = context;
            }
    
            public DataBaseAdapter open() throws SQLException {
                dbHelper = new DBHelper(context);
                database = dbHelper.getWritableDatabase();
                return this;
            }
    
            public void close() {
                dbHelper.close();
            }
    
    
            public Cursor fetchAllTAble1data() {
                return database.query("MenuData", new String[] { "id", "Title",
                        "Image", "Description" }, null, null, null, null, null);
            }
    
            public Cursor fetchAllTable2data() {
                return database.query("RestaurantsData", new String[] {
                        "restaurant_id", "name", "phone", "email", "open_days",
                        "timing", "website", "loc_name", "street", "city", "longitude",
                        "latitude", "zip" }, null, null, null, null, null);
            }
    
            public void deleteTable(String tablename){
                database.execSQL("drop table if exists "+tablename+';');
            }
            public void createIndividualTable(String query){
                database.execSQL(query);
            }
    
    
            public void InsertTable1Data(TAble1 review) {
                ContentValues values = new ContentValues();
                values.put("Name", review.Name);
                values.put("Email", review.Email);
                values.put("Comment", review.Comment);
                values.put("Rating", review.Rating);
    
                database.insert("ReviewsData", null, values);
    
            }
    
            public void InsertTable2Data(TAble2 photos) {
                ContentValues values = new ContentValues();
                values.put("photo", photos.Photos);
    
                database.insert("PhotosData", null, values);
    
            }
    
    
    
            public ContentValues createContentValues(String category, String summary,
                    String description) {
                ContentValues values = new ContentValues();
    
                return values;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have created one android application that was connecting to sqlite database. and i
I have a problem on Android Spinner.In my application I created two Spinner on
I have created an application in Android that needs to send emails to all
I am developing an android database application in which i have to add multiple
I want to create a database for my android application. I have written the
I am developing an android application in which I have created a database named
I have an SQLite database. I created the tables and filled them with a
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
I have a database that I have created using SQL Server Developer 2008. I
I have created one user named tuser with create database rights in SQL server

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.