Cannot find table error when inserting data into database Android -
I am using datbase to store group details and contact information in the database, but whenever I am in databases Insert some data. I'm not saying "no such table" error. What have I done wrong?
Public class GroupDataBase Extended SQLiteOpenHelper {Personal Static last int dbVersion = 1; Personal fixed final string dbn name = "hssecurity"; Private static final string tagname = "group description"; Private static final string groupId = "groupId"; Private static final string groupname = "group name"; Personal fixed final string created = "created"; Personal stable final string createTable = "create table" + + tablename + "(" + + groupID + "integer primary key auto increment," + groupname + "text," + created + "text" + ")"; Public group database (reference reference) {super (references, DBN name, blank, dBearsean); } @ Override Creature on Public Zero (SQLiteDatabase sqLiteDatabase) {sqLiteDatabase.execSQL (createTable); } @ Override Upgrade to Public Zero (SQLiteDatabase sqLiteDatabase, int i, int i2) {} Public Zero Insert Group Details (GroupModel Group Model) {SQLite Database Database = Friendly Database (); Database.beginTransaction (); Content value content value = new content value (); ContentValues.put (GroupName, GroupModel.getGroupName ()); ContentValues.put (created on, groupModel.getGroupCreatedDate ()); If (contentValues! = Null) {long ID = database.instant (tagname, empty, content value); Logs. E ("enter value group", "" + ID); } Database.setTransactionSuccessful (); Database.endTransaction (); Database.close (); }}
LOGCAT
08-01 12: 57: 26.129 2522-2522 / example.com.pocketdocs E / SQLite log: (1) such as None Table: Error in inserting the group details 08-01 12: 57: 26.129 2522-2522 / example.com.pocketdocs E / SQLDatabase: = 2014-08-01 GroupName = test android.database.sqlite.SQLiteException: No such tables: Group description (code 1):, while compiling: INSERTDetails in group (createdOn, groupName) VALUES (?,?) On Android.database.sqlite.SQLiteConnection.nativePrepareStatement (original method) android.database.sqlite .SQLiteConnection.acquirePreparedStatement (SQLiteConnection.java: 893) at android.database.sqlite.SQLiteConnection.prepare (android.database.sqlit E.SQLiteSession.prepare) and SQLiteConnection.prepare (SQLiteSession.java; 88) and android.database.sqlite.SQLite programs. & Lt; Init & gt; (SQLiteProgram.java:58) android.database.sqlite.SQLiteStatement & Lt; Init & gt; (SQLiteStatement.java31) At android.database.sqlite.SQLiteDatabase.insertWithOnConflict (SQLiteDatabase.java1475) android.database.sqlite.SQLiteDatabase.inert (SQLiteDatabase.java:1347) example.com.pocketdocs.DataBase.GroupDataBase.insertGroupDetails (GroupDataBase .java): 50) click example.com.pocketdocs.Group.CreateNewGroup.on (CreateNewGroup.java:87) android.view.View.performClick (see Java: 4147) android.view.View at $ PerformClick See .run (see Java: 17161) and callback at android.os.Handler.handle (handler.java: 615) Android.OS. Handler Dispect Message (Handler. Java: 92) Android.OS Lopper On java.lang.reflect.Method.invoke (method.java + 11) on Com.android on Loop (Looper Java 1313) android.app.ActivityThread.main on java.lang.reflect.Method.invokeNative (Basic method) (ActivityThread.java:4787). Internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:789) on Dalvik.system.NativeStart.main (com). Com.android.internal.os.ZygoteInit.main (ZygoteInit.java) 56) (Original method) 08-01 12: 57: 26.129 2522-2522 / example.com.pocketdocs E / Group Value Added: -1
Did I make the table versus wrong ????
There is a syntax error in your CREATE TABLE
: There should be no space between / code> and
increments
.
Since you are not seeing an exception about this, your onCreate ()
has not run in its present form.
-
Correct the syntax: Use
autoincrement
. -
Uninstall your app so that the database is rebuilt. See for more.
Comments
Post a Comment