android.database.sqlite.SQLiteConstraintException:
Logcat :
E/SQLiteDatabase: Error inserting Email_ID=1234567 USER_ID=abcd13
Password=a#g.com Mobile=1234567890 Name=asdf
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint
failed: User.USER_ID (code 1555)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native
Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:780)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1471)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
at edmt.dev.androidgridlayout.DatabaseHelper.saveUserData(DatabaseHelper.java:555)
at edmt.dev.androidgridlayout.Register$1.onClick(Register.java:80)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21168)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Application terminated.
1
source edit rollback
Your database already has row with USER_ID=adcd13, therefore you must either update the row or remove it and insert again.
Related
I am testing my android app using the android studio also I am using a lot of libraries from GitHub and my problem is when I check LogCat, it showing the unknown message from my phone there is no related app has installed to get this type of message.
What is the problem is my app is hacked?
0-23 12:41:56.486 19337-19379/? E/SQLiteDatabase: Error inserting imdata={"sender":"1007787459425466","is_video":true,"filesize":4229475,"alias":"aswin ps","original_id":".8HGNxeIGQGYKGdwELDentPbijFS","public_level":1,"sim_iso":"IN","type":"video"} is_public=1 buid=fof:fof object_id=.8HGNxeIGQGYKGdwELDentPbijFS original_id=.8HGNxeIGQGYKGdwELDentPbijFS view_type=1 timestamp=1540262393 group_num=0 message_read=0
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: stories.buid, stories.object_id (code 2067)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:780)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1471)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
at com.imo.android.imoim.util.v.a(SourceFile:79)
at com.imo.android.imoim.util.h.doInBackground(SourceFile:1026)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
10-02 01:31:57.697 22242-22242/com.example.android.mynotes E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.mynotes, PID: 22242
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:5697)
at android.widget.TextView.performClick(TextView.java:10826)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5697)
at android.widget.TextView.performClick(TextView.java:10826)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.database.sqlite.SQLiteException: near "EXISTName": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTName(ID INTEGER PRIMARY KEY,TitleTEXT,DescriptionTEXT);
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(near "EXISTName": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTName(ID INTEGER PRIMARY KEY,TitleTEXT,DescriptionTEXT);)
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1058)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:623)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1812)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1743)
at com.example.android.mynotes.DbManager$DatabaseHelperNotes.onCreate(DbManager.kt:32)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.android.mynotes.DbManager.<init>(DbManager.kt:22)
at com.example.android.mynotes.AddNotes.BtnAdd(AddNotes.kt:19)
... 12 more
CREATE TABLE IF NOT EXISTName
You are missing a space between the keyword EXIST and the table name Name.
You can simply add the block of code in a try-catch block and then put debug point on it and determine the exception and correct it.
e.g
try
{
//block of code in which you have an error or you want to debug
}
catch(e: Exception)
{
// you can use log for seeing error or you can simply view errors by
//putting debug point and pressing alt+mouse_left_click after executing
//line to get value of exception instance
}
Although This question has been asked many time but they all are discussing about Sqlite Database. But in my Application I am using Content Provider for database. and I am using this for chat window.Using aSmack Lib.
Below is exception I am getting.
Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1188)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:267)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.adgyde.android.j.<init>(Unknown Source)
at com.adgyde.android.h.f(Unknown Source)
at com.adgyde.android.h.a(Unknown Source)
at com.adgyde.android.o.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5318)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)
Note:
I am getting this on fewer devices Like Vivo,Intex etc. But not on other devices Like Moto G,Samsung Note etc.
Some body has suggested about Write Storage permssion,Which I have declared in manifest. Other has suggested to ask at run time.
Please help me in right direction.
I have got the errors like this when run the above code. Please help me..
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.kalya.farmers1, PID: 32178
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kalya.farmers1/com.example.kalya.farmers1.Harvestitems}: android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.access$800(ActivityThread.java:183)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5651)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1
at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:360)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:254)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.kalya.farmers1.DataBaseHandler.getAllContacts(DataBaseHandler.java:97)
at com.example.kalya.farmers1.Harvestitems.onCreate(Harvestitems.java:43)
at android.app.Activity.performCreate(Activity.java:6119)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2491)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.access$800(ActivityThread.java:183)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5651)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
I/Process: Sending signal. PID: 32178 SIG: 9
Application terminated.
android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1 seems that the error is that you are trying to change the database version from 2 to 1. Try to reset the database version to 2 or maybe if you had made some modifications try to set the version to 3.
Maybe will be helpful if you can post some code too.
i know there exists many posts regarding this issue but the issue i am facing goes like this..
The app works perfectly when run on 4.0,5.0,5.1,6 ets
"SQLiteCantOpenDatabaseException: unknown error (code 14): Could not
open database"
if its run i 4.0.1,5.0.2 or 6.0.1 or to be in general X.0.X but works fine in X.1.X
can any one help me out with this issue
My crash logs proof:
USER_COMMENT=null
ANDROID_VERSION=6.0.1
APP_VERSION_NAME=0.0337
BRAND=google
PHONE_MODEL=Nexus 5
CUSTOM_DATA=
STACK_TRACE=java.lang.RuntimeException: Unable to start receiver com.evernews.evernews.AlarmReceiver: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2732)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
at com.evernews.evernews.AlarmReceiver.onReceive(AlarmReceiver.java:48)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2725)
... 8 more
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
at com.evernews.evernews.AlarmReceiver.onReceive(AlarmReceiver.java:48)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2725)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
One more version :
USER_COMMENT=null
ANDROID_VERSION=5.0.2
APP_VERSION_NAME=0.0337
BRAND=htc
PHONE_MODEL=HTC Desire 816 dual sim
CUSTOM_DATA=
STACK_TRACE=android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:235)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:219)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:854)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:834)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:737)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:712)
at com.evernews.evernews.Main.parseResultsRefresh(Main.java:1194)
at com.evernews.evernews.Main$GetNewsTaskRestart.onPostExecute(Main.java:827)
at com.evernews.evernews.Main$GetNewsTaskRestart.onPostExecute(Main.java:778)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)