Skip to main content

database insertion working well on android emulator but not on device



I have created a database using this tutorial .





When I insert the values in my table, it works on the emulator and I have seen the values are inserted correctly. But when I run my application on a device, it gives me this error:







02-29 17:30:45.341: E/Database(3300):android.database.sqlite.SQLiteException:no such table: recently_used: , while compiling: INSERT INTO recently_used(iconsset_name, icon_name) VALUES(?, ?);

02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)

02-29 17:30:45.341: E/Database(3300):at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)

02-29 17:30:45.341: E/Database(3300):at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)

02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)

02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteStatement.<init> (SQLiteStatement.java:41)







Here is my database class.







public class DBHelpter extends SQLiteOpenHelper{



private static final String DATABASE_NAME = "DatabaseName.db";



public static final String ICONS_SET_TABLE_NAME = "iconset";

public static final String ID_ICONS_SET = "_id";

public static final String NAME_ICONS_SET ="name";

public static final String SERVER_ID_ICONS_SET = "serverid";

public static final String PRODUCT_ID_ICONSET = "productid";



public static final String ICON_TABLE_NAME = "icons";

public static final String ID_ICONS = "_id";



public static final String SERVER_ICON_ID = "serverid";

public static final String ICONSET_ID_ICONS = "iconsetid";



public static final String RECENTLY_USED_TABLE_NAME = "recently_used";

public static final String ICONS_NAME_RECENTLY = "icon_name";

public static final String ICONSSET_NAME_RECENTLY = "iconsset_name";

public static final String RECENTLY_ICONSET_ID = "_id";





public static final int DATABASE_VERSION_NO = 3;

public Context mContext = null;



public static final String mIconsSetQuery = "CREATE TABLE "+ICONS_SET_TABLE_NAME + "(" + ID_ICONS_SET +" INTEGER PRIMARY KEY AUTOINCREMENT," + NAME_ICONS_SET +" TEXT," + SERVER_ID_ICONS_SET +" INTEGER," + PRODUCT_ID_ICONSET +" TEXT);";

public static final String mIcons = "CREATE TABLE "+ ICON_TABLE_NAME + "(" + ID_ICONS+ " INTEGER PRIMARY KEY AUTOINCREMENT,"+ SERVER_ICON_ID + " INTEGER,"+ICONSET_ID_ICONS + " INTEGER);";

public static final String recently_table_query = "CREATE TABLE "+ RECENTLY_USED_TABLE_NAME + "(_id INTEGER PRIMARY KEY AUTOINCREMENT, icon_name TEXT,iconsset_name TEXT);";



public DBHelpter(Context context) {



super(context, DATABASE_NAME, null, DATABASE_VERSION_NO);

mContext = context;

}



@Override

public synchronized void close() {

super.close();

}



@Override

public synchronized SQLiteDatabase getReadableDatabase() {

return super.getReadableDatabase();

}



@Override

public synchronized SQLiteDatabase getWritableDatabase() {

return super.getWritableDatabase();

}



@Override

public void onCreate(SQLiteDatabase db) {



db.execSQL(mIconsSetQuery);

db.execSQL(mIcons);

db.execSQL(recently_table_query);



}



@Override

public void onOpen(SQLiteDatabase db) {

super.onOpen(db);

}



@Override

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

db.execSQL("DROP TABLE IF EXISTS " + ICONS_SET_TABLE_NAME);

db.execSQL("DROP TABLE IF EXISTS " + ICON_TABLE_NAME);

db.execSQL("DROP TABLE IF EXISTS " + RECENTLY_USED_TABLE_NAME);



onCreate(db);

}

}







Here is the method i am using.







public void recentlyUsed(RecentlyUsedIcons recentlyUsedIcons) {



values.put(DBHelpter.ICONS_NAME_RECENTLY, recentlyUsedIcons.getIcon_name());

values.put(DBHelpter.ICONSSET_NAME_RECENTLY, recentlyUsedIcons.getIconSet_name());

mDatabase.insert(DBHelpter.RECENTLY_USED_TABLE_NAME, null, values);







}


Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?

CCNA 3 Final Exam => latest version

1 . Which security protocol or measure would provide the greatest protection for a wireless LAN? WPA2 cloaking SSIDs shared WEP key MAC address filtering   2 . Refer to the exhibit. All trunk links are operational and all VLANs are allowed on all trunk links. An ARP request is sent by computer 5. Which device or devices will receive this message? only computer 4 computer 3 and RTR-A computer 4 and RTR-A computer 1, computer 2, computer 4, and RTR-A computer 1, computer 2, computer 3, computer 4, and RTR-A all of the computers and the router   3 . Refer to the exhibit. Hosts A and B, connected to hub HB1, attempt to transmit a frame at the same time but a collision occurs. Which hosts will receive the collision jamming signal? only hosts A and B only hosts A, B, and C only hosts A, B, C, and D only hosts A, B, C, and E   4 . Refer to the exhibit. Router RA receives a packet with a source address of 192.168.1.65 and a destination address of 192.168.1.161...