I am new in android development and I had built one app for login and it runs successfully..but when I create another table in database and it gives me error that no such table:customizeformdetails and android.database.sqlite.SQLiteException: no such table: customizeformdetails (code 1): , while compiling: INSERT INTO customizeformdetails(JSON) VALUES (?)
My Code is :LoginDatabseAdapter
static final String DATABASE_NAME = "database";
static final int DATABASE_VERSION = 1;
public static final int NAME_COLUMN = 1;
// TODO: Create public field for each column in your table.
// SQL Statement to create a new database.
static final String DATABASE_CREATE = "CREATE TABLE IF NOT EXISTS"+"adminreg"+
"( " +"AdminRegID"+" integer primary key autoincrement,"+ "Rest_name text,Contact_person_name text,Designation text,Contact_no text,Email_addr text,PASSWORD text,Address text); ";
// Variable to hold the database instance
static final String DATABASE_FEEDBACKFORM="CREATE TABLE IF NOT EXISTS"+"customizeformdetails"+
"("+"CustomizeFormId"+" integer primary key autoincrement,"+"JSON text);";
public SQLiteDatabase db;
// Context of the application using the database.
private final Context context;
// Database open/upgrade helper
private DataBaseHelper dbHelper;
public LoginDatabaseAdapter(Context _context)
{
context = _context;
dbHelper = new DataBaseHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public LoginDatabaseAdapter open() throws SQLException
{
db = dbHelper.getWritableDatabase();
return this;
}
public void close()
{
db.close();
}
public SQLiteDatabase getDatabaseInstance()
{
return db;
}
public void insertEntry(String Rest_name,String Contact_person_name,String Designation,String Contact_no,String Email_addr,String PASSWORD, String Address)
{
ContentValues newValues = new ContentValues();
// Assign values for each row.
newValues.put("Rest_name", Rest_name);
newValues.put("Contact_person_name",Contact_person_name);
newValues.put("Designation",Designation);
newValues.put("Contact_no",Contact_no);
newValues.put("Email_addr",Email_addr);
newValues.put("PASSWORD",PASSWORD);
newValues.put("Address",Address);
// Insert the row into your table
db.insert("adminreg", null, newValues);
Toast.makeText(context, "Reminder Is Successfully Saved", Toast.LENGTH_LONG).show();
Log.e("context", "Toast");
}
public void insertCustomizeEntry(String json)
{
Log.e("Data Insert reached","yes");
ContentValues newValues = new ContentValues();
newValues.put("JSON",json);
db.insert("customizeformdetails", null, newValues);
Toast.makeText(context, "Data Is Successfully Saved", Toast.LENGTH_LONG).show();
Log.e("context", "Toast");
selectCustomizeEntry();
}
public String selectCustomizeEntry()
{
Cursor cursor=db.rawQuery("SELECT * FROM customizeformdetails", null);
if(cursor.getCount()<1) // UserName Not Exist
{
cursor.close();
return "NOT EXIST";
}
cursor.moveToFirst();
String customizeFormDetails= cursor.getString(cursor.getColumnIndex("JSON"));
Log.e("Data",customizeFormDetails);
return customizeFormDetails;
}
DatabseHelper.cs :
public DataBaseHelper(Context context, String name,SQLiteDatabase.CursorFactory factory, int version)
{
super(context, name, factory, version);
}
// Called when no database exists in disk and the helper class needs
// to create a new one.
@Override
public void onCreate(SQLiteDatabase _db)
{
_db.execSQL("DROP TABLE IF EXISTS " + LoginDatabaseAdapter.DATABASE_FEEDBACKFORM);
_db.execSQL(LoginDatabaseAdapter.DATABASE_CREATE);
_db.execSQL(LoginDatabaseAdapter.DATABASE_FEEDBACKFORM);
}
Please help me..It already taken so much time
Aucun commentaire:
Enregistrer un commentaire