Java Code Examples for android.database.sqlite.SQLiteConstraintException#printStackTrace()

The following examples show how to use android.database.sqlite.SQLiteConstraintException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyCameraDB.java    From CameraViewer with Apache License 2.0 5 votes vote down vote up
public boolean deleteMyCamera(MyCameraInfo myCamera) {
    try {
        mDatabase.execSQL("DELETE FROM MyCamera WHERE IP=? AND PORT=?", new String[]{myCamera.getIP(), myCamera.getPort() + ""});
        return true;
    } catch (SQLiteConstraintException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example 2
Source File: MyCameraDB.java    From CameraViewer with Apache License 2.0 5 votes vote down vote up
public boolean saveMyCamera(MyCameraInfo myCameraInfo) {
    try {
        mDatabase.execSQL("INSERT INTO MyCamera(IP,PORT,PASSWORD,NOTE,DEVICE_ID,CAM_NUMBER,TYPE) VALUES (?,?,?,?,?,?,?)",
                new String[]{myCameraInfo.getIP(), myCameraInfo.getPort() + "", myCameraInfo.getPassword(), myCameraInfo.getNote(),
                        myCameraInfo.getDeviceId(), myCameraInfo.getCamNumber() + "", myCameraInfo.getType() + ""});
        return true;
    } catch (SQLiteConstraintException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example 3
Source File: MyCameraDB.java    From CameraViewer with Apache License 2.0 5 votes vote down vote up
public boolean updateMyCamera(String oldIP, int oldPort, MyCameraInfo myCameraInfo) {
    try {
        mDatabase.execSQL("UPDATE MyCamera SET IP=?,PORT=?,PASSWORD=?,NOTE=?,DEVICE_ID=?,CAM_NUMBER=?,TYPE=? WHERE IP=? AND PORT=?", new String[]{
                myCameraInfo.getIP(), myCameraInfo.getPort() + "", myCameraInfo.getPassword(), myCameraInfo.getNote(), myCameraInfo.getDeviceId(), myCameraInfo.getCamNumber() + "", myCameraInfo.getType() + "",
                oldIP, oldPort + ""
        });
        return true;
    } catch (SQLiteConstraintException e) {
        e.printStackTrace();
    }
    return false;
}