Example usage for android.database.sqlite SQLiteConstraintException getMessage

List of usage examples for android.database.sqlite SQLiteConstraintException getMessage

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteConstraintException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.prx.prp.utility.ParsedJSONObject.java

public void sync(String modelName) {
    try {/*from  www  .j  av a  2s  .  co m*/
        if (this.toBeDeleted) {
            DatabaseAdapter.deleteRecord(modelName, new String[] { "id" }, new String[] { id.toString() });
        } else {
            ContentValues params = new ContentValues();
            for (int index = 0; index < names.length; index++) {
                params.put(names[index], values[index]);
            }
            DatabaseAdapter.insertRecord(modelName, params);
        }

    } catch (SQLiteConstraintException e) {
        Log.d("PRPAND", e.getMessage());
    }

}

From source file:com.example.android.rowanparkingpass.Networking.Sync.SyncVehicles.java

public synchronized void sync(Context c) {
    if (SaveData.getSync()) {
        SendInfoVehicle sendInfoVehicle = new SendInfoVehicle();
        JSONObject json = sendInfoVehicle.syncVehicles(c);
        JSONArray jsonArray;//w ww . j a v  a2s.c om
        States[] arrayStates = States.values();
        try {
            String s = json.getString("JSONS");
            s = URLDecoder.decode(s);
            Log.d("Sssssss", s);
            jsonArray = new JSONArray(s);
            Log.d("JSON ARRAY", jsonArray.toString());
            DatabaseHandlerVehicles db = new DatabaseHandlerVehicles(c);
            for (int i = 0; i < jsonArray.length(); i++) {
                //[{"model":"zaz","color":"1","state":"23","user_id":"10","year":"1945","license":"bingling","vehicle_id":"3","make":"me a sammich"}
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                //Log.d("JSONOBJ", jsonObj.toString());
                String model = jsonObj.getString("model");
                String color = jsonObj.getString("color");
                String state = jsonObj.getString("state");
                String year = jsonObj.getString("year");
                String license = jsonObj.getString("license");
                String vehicle_id = jsonObj.getString("vehicle_id");
                String make = jsonObj.getString("make");
                try {
                    db.addVehicle(Integer.parseInt(vehicle_id), Integer.parseInt(year), make, model,
                            arrayStates[Integer.parseInt(state)]
                                    .valueOf(arrayStates[Integer.parseInt(state)].name()).toString(),
                            color, license);
                } catch (SQLiteConstraintException sqlC) {
                    Log.d("SQLite Exception", sqlC.getMessage());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

From source file:com.example.android.rowanparkingpass.Networking.Sync.SyncDrivers.java

public synchronized void sync(Context c) {
    if (SaveData.getSync()) {
        SendInfoDriver sendInfoDriver = new SendInfoDriver();
        JSONObject json = sendInfoDriver.syncDrivers(c);
        JSONArray jsonArray;//from   ww  w  . j av a  2s . c om
        States[] arrayStates = States.values();
        try {
            String s = json.getString("JSONS");
            s = URLDecoder.decode(s);
            Log.d("S", s);
            jsonArray = new JSONArray(s);
            Log.d("JSON ARRAY", jsonArray.toString());
            DatabaseHandlerDrivers db = new DatabaseHandlerDrivers(c);
            for (int i = 0; i < jsonArray.length(); i++) {
                //[{"model":"zaz","color":"1","state":"23","user_id":"10","year":"1945","license":"bingling","vehicle_id":"3","make":"me a sammich"}

                JSONObject jsonObj = jsonArray.getJSONObject(i);
                //Log.d("JSONOBJ", jsonObj.toString());
                String driverID = jsonObj.getString("driver_id");
                String fullName = jsonObj.getString("full_name");
                String street = jsonObj.getString("street");
                String city = jsonObj.getString("city");
                String state = jsonObj.getString("state");
                String zip = Utilities.appendZipZero(jsonObj.getString("zip"));
                try {
                    db.addDriver(Integer.parseInt(driverID), Utilities.fakeByte, fullName, street, city,
                            arrayStates[Integer.parseInt(state)]
                                    .valueOf(arrayStates[Integer.parseInt(state)].name()).toString(),
                            zip);
                } catch (SQLiteConstraintException sqlC) {
                    Log.d("SQLite Exception", sqlC.getMessage());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

From source file:br.unisinos.evertonlucas.passshelter.app.ResourceActivity.java

public void btnSaveResource(View view) {
    try {//from  w  w  w  . j  av a  2s .  c  o  m
        verifyResourceName();
        verifyUserName();
        verifyPasswordName();

        this.resource = fillResourceFromFields(this.resource);

        this.resourceRep.saveResource(resource);
        NavUtils.navigateUpFromSameTask(this);
    } catch (SQLiteConstraintException e) {
        Toast.makeText(this, "Recurso j salvo anteriormente", Toast.LENGTH_LONG).show();
    } catch (IllegalArgumentException e) {
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
    } catch (Exception e) {
        ShowLogExceptionUtil.showAndLogException(this, "Erro ao salvar recurso", e);
    }
}

From source file:com.mobicage.rpc.http.HttpProtocol.java

private void process(RpcCall call) {
    L.d("Process incoming call " + call.function + " / " + call.callId);

    try {/*from   w w  w. j a v  a2s .c om*/
        mBacklog.insertNewIncomingCallInDb(call);
    } catch (SQLiteConstraintException e) {
        if (mBacklog.hasBodyForCallId(call.callId)) {
            onCallProcessed(call.callId);
            return;
        } else {
            L.d("Duplicate processing: " + call.callId);
        }
    } catch (Exception e) {
        L.bug(e);
        return;
    }

    RpcResult rpcResult;
    try {
        IJSONable result = CallReceiver.processCall(call);
        rpcResult = new RpcResult(call, result == null ? null : result.toJSONMap());
    } catch (Exception e) {
        rpcResult = new RpcResult(call, e.getMessage() + "\n" + L.getStackTraceString(e));
        L.bug(e);
    }

    mBacklog.updateBody(rpcResult);

    onCallProcessed(call.callId);
    return;
}

From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java

long insertSubscriber(SQLiteDatabase db, ContentValues cv) {
    try {//w ww  .  ja v a2 s  .  co  m
        String feedName = cv.getAsString(Subscriber.FEED_NAME);
        validate(feedName);
        return db.insertOrThrow(Subscriber.TABLE, null, cv);
    } catch (SQLiteConstraintException e) {
        //this inserts dupes, so hide this spam in a way 
        //that doesn't require api level 8
        return -1;
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        return -1;
    }
}