It works fine when a user puts in the correct ID but breaks when its incorrect, username is a int which is my primary key i want to catch the exception and tell the user incorrect id, but what exception do i need? or how do i catch sql lite exceptions any help is much appreciated!
The easiest way is to use the SDK's SQLiteDatabase 's insert method and assume that a failed insert (the long returned is -1 rather then 1 or greater).
If you wanted more specific control/error handling then you could use the SQLiteDatabase 's insertOrThrow method to then handle the SQLiteConstraintException .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.