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

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex