As part of my Big data training projects, I’m trying to insert a big data in SQLite like spinner selected item , date time, and string. When I run the app I got:
SQLite exception : No Such Table while compiling for insert into. database
I don’t know how to do.
Here is database Code
public class DataBase_Adapter
{
//Database NAme
static final String DATABASE_NAME = "lead_management.db";
//Database Version
static final int DATABASE_VERSION = 1;
// Variable to hold the database instance
public SQLiteDatabase db;
// Context of the application using the database.
private final Context context;
// Database open/upgrade helper
private DataBaseHelper dbHelper;
public DataBase_Adapter(Context _context)
{
context = _context;
dbHelper = new DataBaseHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public DataBase_Adapter open() throws SQLException
{
db = dbHelper.getWritableDatabase();
return this;
}
public void close()
{
db.close();
}
public SQLiteDatabase getDatabaseInstance()
{
return db;
}
//Table name
static final String TABLE_NEW_LEAD="new_lead";
//Creating New Lead Table Columns
private static final String KEY_NEW_LEAD_ID ="id";
private static final String KEY_NEW_LEAD_NAME ="name";
private static final String KEY_NEW_LEAD_EMAIL ="email";
private static final String KEY_NEW_LEAD_MOBILE="mobile";
private static final String KEY_NEW_LEAD_Product="define_products";
private static final String KEY_NEW_LEAD_BUDGET="budget";
private static final String KEY_NEW_LEAD_PRIORITY="priority";
private static final String KEY_NEW_LEAD_STATUS="status";
private static final String KEY_NEW_LEAD_NOTES="notes";
private static final String KEY_NEW_LEAD_REMINDER_DATE="reminder_date";
private static final String KEY_NEW_LEAD_REMINDER_TIME="reminder_time";
private static final String KEY_NEW_LEAD_ADDtoCONTACTS="add_to_contacts";
//// SQL Statement to create a New Lead Database.
static final String CREATE_NEW_LEAD_TABLE = "CREATE TABLE"+TABLE_NEW_LEAD+"("+KEY_NEW_LEAD_ID+"integer primary key autoincrement,"+KEY_NEW_LEAD_NAME+"TEXT,"+KEY_NEW_LEAD_EMAIL+"TEXT,"+ KEY_NEW_LEAD_MOBILE+"TEXT,"+KEY_NEW_LEAD_Product+"TEXT,"+KEY_NEW_LEAD_BUDGET+"TEXT,"+KEY_NEW_LEAD_PRIORITY+"TEXT,"+KEY_NEW_LEAD_STATUS+"TEXT,"+KEY_NEW_LEAD_NOTES+"TEXT,"+KEY_NEW_LEAD_REMINDER_DATE+"TEXT,"+KEY_NEW_LEAD_REMINDER_TIME +"TEXT,"+KEY_NEW_LEAD_ADDtoCONTACTS+"TEXT,"+")";
//Insert New Record In New Lead Table
public void insert_NewLead_Entry(New_Lead_BeanClass newLead_BeanClass)
{
SQLiteDatabase sdb = dbHelper.getWritableDatabase();
ContentValues contentNewLead_Val=new ContentValues();
contentNewLead_Val.put(KEY_NEW_LEAD_NAME, newLead_BeanClass.get_Name());
contentNewLead_Val.put(KEY_NEW_LEAD_EMAIL, newLead_BeanClass.get_Email());
contentNewLead_Val.put(KEY_NEW_LEAD_MOBILE, newLead_BeanClass.get_MobileNo());
contentNewLead_Val.put(KEY_NEW_LEAD_Product, newLead_BeanClass.get_Product());
contentNewLead_Val.put(KEY_NEW_LEAD_BUDGET, newLead_BeanClass.get_Budget());
contentNewLead_Val.put(KEY_NEW_LEAD_PRIORITY, newLead_BeanClass.get_Priority());
contentNewLead_Val.put(KEY_NEW_LEAD_STATUS, newLead_BeanClass.get_Status());
contentNewLead_Val.put(KEY_NEW_LEAD_NOTES, newLead_BeanClass.get_Notes());
contentNewLead_Val.put(KEY_NEW_LEAD_REMINDER_DATE, newLead_BeanClass.get_Reminder_Date());
contentNewLead_Val.put(KEY_NEW_LEAD_REMINDER_TIME, newLead_BeanClass.get_Reminder_Time());
contentNewLead_Val.put(KEY_NEW_LEAD_ADDtoCONTACTS, newLead_BeanClass.get_AddtoContact());
sdb.insert(TABLE_NEW_LEAD , null , contentNewLead_Val );
//Close The Database Connection
sdb.close();
}
}