List of usage examples for android.content ContentValues clear
public void clear()
From source file:com.osfans.trime.DictionaryHelper.java
private boolean importDict(InputStream is) { boolean success = false; SQLiteDatabase db = getWritableDatabase(); db.beginTransaction();//from ww w.j a v a2s. c om try { String line; StringBuilder content = new StringBuilder(); InputStreamReader ir = new InputStreamReader(is); BufferedReader br = new BufferedReader(ir); while ((line = br.readLine()) != null && !line.contentEquals(fs)) { content.append(line); content.append(newline); } Yaml yaml = new Yaml(); Map<String, Object> y = (Map<String, Object>) (yaml.load(content.toString())); String table = (String) y.get("name"); db.execSQL("DROP TABLE IF EXISTS " + table); db.execSQL(String.format("CREATE VIRTUAL TABLE %s USING fts3(hz, py)", table)); ContentValues initialValues = new ContentValues(2); int max = is.available(); int progress = 0; int count = 0; while ((line = br.readLine()) != null) { if (line.startsWith(comment)) continue; String[] s = line.split("\t"); if (s.length < 2) continue; initialValues.put("hz", s[0]); initialValues.put("py", s[1]); db.insert(table, null, initialValues); initialValues.clear(); count++; if ((count % 1000) == 0) { progress = max - is.available(); mBuilder.setProgress(max, progress, false) .setContentText(String.format("%d / 100", progress * 100 / max)); mNotifyManager.notify(notify_id, mBuilder.build()); } } is.close(); db.setTransactionSuccessful(); success = true; } catch (Exception e) { throw new RuntimeException("Error import dict", e); } finally { db.endTransaction(); mNotifyManager.cancel(notify_id); } return success; }
From source file:com.noshufou.android.su.service.ResultService.java
private void addLog(long appId, int callerUid, int execUid, String execCmd, int allow, long currentTime, String appLog, int all) { // Check to see if we should log if ((appLog == null && !mLog) || (appLog != null && appLog.equals("0")) || allow == -1) { return;//from www . j a v a 2s .com } ContentValues values = new ContentValues(); if (appId == -1) { // App was not found in the database, add a row for logging purposes values.put(Apps.UID, callerUid); values.put(Apps.PACKAGE, Util.getAppPackage(this, callerUid)); values.put(Apps.NAME, Util.getAppName(this, callerUid, false)); values.put(Apps.EXEC_UID, execUid); values.put(Apps.EXEC_CMD, execCmd); values.put(Apps.ALLOW, all == 0 ? Apps.AllowType.ASK : allow); appId = Long.parseLong(getContentResolver().insert(Apps.CONTENT_URI, values).getLastPathSegment()); } values.clear(); values.put(Logs.DATE, currentTime); values.put(Logs.TYPE, allow); getContentResolver().insert(Uri.withAppendedPath(Logs.CONTENT_URI, String.valueOf(appId)), values); }
From source file:io.n7.calendar.caldav.CalDAVService.java
private void doSyncCalendar(Account acc, long calid) throws Exception { // Get a list of local events String[] evproj1 = new String[] { Events._ID, Events._SYNC_ID, Events.DELETED, Events._SYNC_DIRTY }; HashMap<String, Long> localevs = new HashMap<String, Long>(); HashMap<String, Long> removedevs = new HashMap<String, Long>(); HashMap<String, Long> dirtyevs = new HashMap<String, Long>(); HashMap<String, Long> newdevevs = new HashMap<String, Long>(); Cursor c = mCR.query(EVENTS_URI, evproj1, Events.CALENDAR_ID + "=" + calid, null, null); long tid;/*w ww .j a va 2 s . c om*/ String tuid = null; if (c.moveToFirst()) { do { tid = c.getLong(0); tuid = c.getString(1); if (c.getInt(2) != 0) removedevs.put(tuid, tid); else if (tuid == null) { // generate a UUID tuid = UUID.randomUUID().toString(); newdevevs.put(tuid, tid); } else if (c.getInt(3) != 0) dirtyevs.put(tuid, tid); else localevs.put(tuid, tid); } while (c.moveToNext()); c.close(); } CalDAV4jIf caldavif = new CalDAV4jIf(getAssets()); caldavif.setCredentials(new CaldavCredential(acc.getProtocol(), acc.getHost(), acc.getPort(), acc.getHome(), acc.getCollection(), acc.getUser(), acc.getPassword())); //add new device events to server for (String uid : newdevevs.keySet()) addEventOnServer(uid, newdevevs.get(uid), caldavif); //delete the locally removed events on server for (String uid : removedevs.keySet()) { removeEventOnServer(uid, caldavif); // clean up provider DB? removeLocalEvent(removedevs.get(uid)); } //update the dirty events on server for (String uid : dirtyevs.keySet()) updateEventOnServer(uid, dirtyevs.get(uid), caldavif); // Get events from server VEvent[] evs = caldavif.getEvents(); // add/update to provider DB String[] evproj = new String[] { Events._ID }; ContentValues cv = new ContentValues(); String temp, durstr = null; for (VEvent v : evs) { cv.clear(); durstr = null; String uid = ICalendarUtils.getUIDValue(v); // XXX Some times the server seem to return the deleted event if we do get events immediately // after removing.. // So ignore the possibility of deleted event on server was modified on server, for now. if (removedevs.containsKey(uid)) continue; //TODO: put etag here cv.put(Events._SYNC_ID, uid); //UUID cv.put(Events._SYNC_DATA, uid); cv.put(Events.CALENDAR_ID, calid); cv.put(Events.TITLE, ICalendarUtils.getSummaryValue(v)); cv.put(Events.DESCRIPTION, ICalendarUtils.getPropertyValue(v, Property.DESCRIPTION)); cv.put(Events.EVENT_LOCATION, ICalendarUtils.getPropertyValue(v, Property.LOCATION)); String tzid = ICalendarUtils.getPropertyValue(v, Property.TZID); if (tzid == null) tzid = Time.getCurrentTimezone(); cv.put(Events.EVENT_TIMEZONE, tzid); long dtstart = parseDateTimeToMillis(ICalendarUtils.getPropertyValue(v, Property.DTSTART), tzid); cv.put(Events.DTSTART, dtstart); temp = ICalendarUtils.getPropertyValue(v, Property.DTEND); if (temp != null) cv.put(Events.DTEND, parseDateTimeToMillis(temp, tzid)); else { temp = ICalendarUtils.getPropertyValue(v, Property.DURATION); durstr = temp; if (temp != null) { cv.put(Events.DURATION, durstr); // We still need to calculate and enter DTEND. Otherwise, the Android is not displaying // the event properly Duration dur = new Duration(); dur.parse(temp); cv.put(Events.DTEND, dtstart + dur.getMillis()); } } //TODO add more fields //if the event is already present, update it otherwise insert it // TODO find if something changed on server using etag Uri euri; if (localevs.containsKey(uid) || dirtyevs.containsKey(uid)) { if (localevs.containsKey(uid)) { tid = localevs.get(uid); localevs.remove(uid); } else { tid = dirtyevs.get(uid); dirtyevs.remove(uid); } mCR.update(ContentUris.withAppendedId(EVENTS_URI, tid), cv, null, null); //clear sync dirty flag cv.clear(); cv.put(Events._SYNC_DIRTY, 0); mCR.update(ContentUris.withAppendedId(EVENTS_URI, tid), cv, null, null); Log.d(TAG, "Updated " + uid); } else if (!newdevevs.containsKey(uid)) { euri = mCR.insert(EVENTS_URI, cv); Log.d(TAG, "Inserted " + uid); } } // the remaining events in local and dirty event list are no longer on the server. So remove them. for (String uid : localevs.keySet()) removeLocalEvent(localevs.get(uid)); //XXX Is this possible? /* for (String uid: dirtyevs.keySet ()) removeLocalEvent (dirtyevs[uid]); */ }
From source file:at.bitfire.davdroid.AccountSettings.java
@SuppressWarnings({ "Recycle", "unused" }) private void update_2_3() { // Don't show a warning for Android updates anymore accountManager.setUserData(account, "last_android_version", null); Long serviceCardDAV = null, serviceCalDAV = null; ServiceDB.OpenHelper dbHelper = new ServiceDB.OpenHelper(context); try {//from ww w .j a v a2 s. c o m SQLiteDatabase db = dbHelper.getWritableDatabase(); // we have to create the WebDAV Service database only from the old address book, calendar and task list URLs // CardDAV: migrate address books ContentProviderClient client = context.getContentResolver() .acquireContentProviderClient(ContactsContract.AUTHORITY); if (client != null) try { LocalAddressBook addrBook = new LocalAddressBook(account, client); String url = addrBook.getURL(); if (url != null) { App.log.fine("Migrating address book " + url); // insert CardDAV service ContentValues values = new ContentValues(); values.put(Services.ACCOUNT_NAME, account.name); values.put(Services.SERVICE, Services.SERVICE_CARDDAV); serviceCardDAV = db.insert(Services._TABLE, null, values); // insert address book values.clear(); values.put(Collections.SERVICE_ID, serviceCardDAV); values.put(Collections.URL, url); values.put(Collections.SYNC, 1); db.insert(Collections._TABLE, null, values); // insert home set HttpUrl homeSet = HttpUrl.parse(url).resolve("../"); values.clear(); values.put(HomeSets.SERVICE_ID, serviceCardDAV); values.put(HomeSets.URL, homeSet.toString()); db.insert(HomeSets._TABLE, null, values); } } catch (ContactsStorageException e) { App.log.log(Level.SEVERE, "Couldn't migrate address book", e); } finally { client.release(); } // CalDAV: migrate calendars + task lists Set<String> collections = new HashSet<>(); Set<HttpUrl> homeSets = new HashSet<>(); client = context.getContentResolver().acquireContentProviderClient(CalendarContract.AUTHORITY); if (client != null) try { LocalCalendar calendars[] = (LocalCalendar[]) LocalCalendar.find(account, client, LocalCalendar.Factory.INSTANCE, null, null); for (LocalCalendar calendar : calendars) { String url = calendar.getName(); App.log.fine("Migrating calendar " + url); collections.add(url); homeSets.add(HttpUrl.parse(url).resolve("../")); } } catch (CalendarStorageException e) { App.log.log(Level.SEVERE, "Couldn't migrate calendars", e); } finally { client.release(); } TaskProvider provider = LocalTaskList.acquireTaskProvider(context.getContentResolver()); if (provider != null) try { LocalTaskList[] taskLists = (LocalTaskList[]) LocalTaskList.find(account, provider, LocalTaskList.Factory.INSTANCE, null, null); for (LocalTaskList taskList : taskLists) { String url = taskList.getSyncId(); App.log.fine("Migrating task list " + url); collections.add(url); homeSets.add(HttpUrl.parse(url).resolve("../")); } } catch (CalendarStorageException e) { App.log.log(Level.SEVERE, "Couldn't migrate task lists", e); } finally { provider.close(); } if (!collections.isEmpty()) { // insert CalDAV service ContentValues values = new ContentValues(); values.put(Services.ACCOUNT_NAME, account.name); values.put(Services.SERVICE, Services.SERVICE_CALDAV); serviceCalDAV = db.insert(Services._TABLE, null, values); // insert collections for (String url : collections) { values.clear(); values.put(Collections.SERVICE_ID, serviceCalDAV); values.put(Collections.URL, url); values.put(Collections.SYNC, 1); db.insert(Collections._TABLE, null, values); } // insert home sets for (HttpUrl homeSet : homeSets) { values.clear(); values.put(HomeSets.SERVICE_ID, serviceCalDAV); values.put(HomeSets.URL, homeSet.toString()); db.insert(HomeSets._TABLE, null, values); } } } finally { dbHelper.close(); } // initiate service detection (refresh) to get display names, colors etc. Intent refresh = new Intent(context, DavService.class); refresh.setAction(DavService.ACTION_REFRESH_COLLECTIONS); if (serviceCardDAV != null) { refresh.putExtra(DavService.EXTRA_DAV_SERVICE_ID, serviceCardDAV); context.startService(refresh); } if (serviceCalDAV != null) { refresh.putExtra(DavService.EXTRA_DAV_SERVICE_ID, serviceCalDAV); context.startService(refresh); } }
From source file:org.zywx.wbpalmstar.plugin.uexcontacts.PFConcactMan.java
public static boolean modify(Context context, ModifyOptionVO modifyOptionVO) { String contactId = modifyOptionVO.getContactId(); String inName = modifyOptionVO.getName(); String inNum = modifyOptionVO.getNum(); String inEmail = modifyOptionVO.getEmail(); int sdkVersion = Build.VERSION.SDK_INT; ContentResolver contentResolver = context.getContentResolver(); boolean isModify = false; if (sdkVersion < 8) { try {/*from w w w . j ava2 s. c om*/ Cursor cusor = null; String[] projection = new String[] { android.provider.Contacts.People._ID, android.provider.Contacts.People.NAME, android.provider.Contacts.People.NUMBER }; String selection = android.provider.Contacts.People._ID + " = ? "; String[] selectionArgs = new String[] { contactId }; cusor = contentResolver.query(android.provider.Contacts.People.CONTENT_URI, projection, selection, selectionArgs, null); cusor.moveToFirst(); while (cusor.moveToNext()) { ContentValues values = new ContentValues(); String nameWhere = android.provider.Contacts.Phones.PERSON_ID + "=? "; values.put(android.provider.Contacts.People.NAME, inName); contentResolver.update(android.provider.Contacts.People.CONTENT_URI, values, nameWhere, selectionArgs); // ??type?????? values.clear(); values.put(android.provider.Contacts.Phones.TYPE, android.provider.Contacts.Phones.TYPE_MOBILE); values.put(android.provider.Contacts.Phones.NUMBER, inNum); String numWhere = android.provider.Contacts.Phones.PERSON_ID + "=? "; contentResolver.update(android.provider.Contacts.Phones.CONTENT_URI, values, numWhere, selectionArgs); // ?type????? values.clear(); values.put(android.provider.Contacts.ContactMethods.KIND, android.provider.Contacts.KIND_EMAIL); values.put(android.provider.Contacts.ContactMethods.DATA, inEmail); values.put(android.provider.Contacts.ContactMethods.TYPE, android.provider.Contacts.ContactMethods.TYPE_HOME); String emailWhere = android.provider.Contacts.ContactMethods.PERSON_ID + "=? "; contentResolver.update(android.provider.Contacts.ContactMethods.CONTENT_URI, values, emailWhere, selectionArgs); isModify = true; } if (cusor != null) cusor.close(); } catch (Exception e) { ToastShow(context, finder.getString(context, "plugin_contact_modify_fail")); return false; } } else if (sdkVersion < 14) { try { String[] projection = new String[] { android.provider.ContactsContract.Contacts.DISPLAY_NAME, android.provider.ContactsContract.Contacts._ID }; String selection = android.provider.ContactsContract.RawContacts.CONTACT_ID + " = ? "; String[] selectionArgs = new String[] { contactId }; Cursor cur = contentResolver.query(android.provider.ContactsContract.RawContacts.CONTENT_URI, projection, selection, selectionArgs, null); cur.moveToFirst(); while (cur.moveToNext()) { ContentValues values = new ContentValues(); values.clear(); values.put(android.provider.ContactsContract.Data.MIMETYPE, android.provider.ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE); values.put(android.provider.ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, inName); String nameWhere = android.provider.ContactsContract.Data.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] nameSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE }; context.getContentResolver().update(android.provider.ContactsContract.Data.CONTENT_URI, values, nameWhere, nameSelection); values.clear(); values.put(android.provider.ContactsContract.CommonDataKinds.Phone.NUMBER, inNum); values.put(android.provider.ContactsContract.CommonDataKinds.Phone.TYPE, android.provider.ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE); String numWhere = android.provider.ContactsContract.Data.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] numSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE, }; context.getContentResolver().update(android.provider.ContactsContract.Data.CONTENT_URI, values, numWhere, numSelection); values.clear(); values.put(android.provider.ContactsContract.Data.MIMETYPE, android.provider.ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE); values.put(android.provider.ContactsContract.CommonDataKinds.Email.DATA, inEmail); values.put(android.provider.ContactsContract.CommonDataKinds.Email.TYPE, android.provider.ContactsContract.CommonDataKinds.Email.TYPE_WORK); String emailWhere = android.provider.ContactsContract.Data.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] emailSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE, }; context.getContentResolver().update(android.provider.ContactsContract.Data.CONTENT_URI, values, emailWhere, emailSelection); isModify = true; } if (cur != null) cur.close(); } catch (Exception e) { ToastShow(context, finder.getString(context, "plugin_contact_modify_fail")); } } else { try { String[] projection = new String[] { android.provider.ContactsContract.Contacts.DISPLAY_NAME, android.provider.ContactsContract.RawContacts._ID }; String selection = android.provider.ContactsContract.RawContacts.CONTACT_ID + " = ? "; String[] selectionArgs = new String[] { contactId }; Cursor cur = contentResolver.query(android.provider.ContactsContract.RawContacts.CONTENT_URI, projection, selection, selectionArgs, null); while (cur.moveToNext()) { ContentValues values = new ContentValues(); values.clear(); values.put(android.provider.ContactsContract.Data.MIMETYPE, android.provider.ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE); values.put(android.provider.ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, inName); String nameWhere = android.provider.ContactsContract.Data.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] nameSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE }; int resultId = context.getContentResolver().update( android.provider.ContactsContract.Data.CONTENT_URI, values, nameWhere, nameSelection); values.clear(); values.put(android.provider.ContactsContract.CommonDataKinds.Phone.NUMBER, inNum); values.put(android.provider.ContactsContract.CommonDataKinds.Phone.TYPE, android.provider.ContactsContract.PhoneLookup.NUMBER); String numWhere = android.provider.ContactsContract.RawContacts.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] numSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE, }; int resultId1 = context.getContentResolver().update( android.provider.ContactsContract.Data.CONTENT_URI, values, numWhere, numSelection); values.clear(); values.put(android.provider.ContactsContract.Data.MIMETYPE, android.provider.ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE); values.put(android.provider.ContactsContract.CommonDataKinds.Email.DATA, inEmail); values.put(android.provider.ContactsContract.CommonDataKinds.Email.TYPE, android.provider.ContactsContract.CommonDataKinds.Email.TYPE_WORK); String emailWhere = android.provider.ContactsContract.RawContacts.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] emailSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE, }; int resultId2 = context.getContentResolver().update( android.provider.ContactsContract.Data.CONTENT_URI, values, emailWhere, emailSelection); isModify = true; } if (cur != null) cur.close(); projection = new String[] { android.provider.ContactsContract.Contacts.DISPLAY_NAME, android.provider.ContactsContract.Contacts._ID }; selection = android.provider.ContactsContract.Contacts._ID + " = ? "; Cursor cursor = context.getContentResolver().query( android.provider.ContactsContract.Contacts.CONTENT_URI, projection, selection, selectionArgs, null); while (cursor.moveToNext()) { ContentValues values = new ContentValues(); values.clear(); values.put(android.provider.ContactsContract.Data.MIMETYPE, android.provider.ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE); values.put(android.provider.ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, inName); String nameWhere = android.provider.ContactsContract.Data.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] nameSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE }; int resultId3 = context.getContentResolver().update( android.provider.ContactsContract.Data.CONTENT_URI, values, nameWhere, nameSelection); values.clear(); values.put(android.provider.ContactsContract.CommonDataKinds.Phone.NUMBER, inNum); values.put(android.provider.ContactsContract.CommonDataKinds.Phone.TYPE, android.provider.ContactsContract.PhoneLookup.NUMBER); String numWhere = android.provider.ContactsContract.RawContacts.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] numSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE, }; int resultId4 = context.getContentResolver().update( android.provider.ContactsContract.Data.CONTENT_URI, values, numWhere, numSelection); values.clear(); values.put(android.provider.ContactsContract.Data.MIMETYPE, android.provider.ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE); values.put(android.provider.ContactsContract.CommonDataKinds.Email.DATA, inEmail); values.put(android.provider.ContactsContract.CommonDataKinds.Email.TYPE, android.provider.ContactsContract.CommonDataKinds.Email.TYPE_WORK); String emailWhere = android.provider.ContactsContract.RawContacts.CONTACT_ID + " = ? AND " + android.provider.ContactsContract.Data.MIMETYPE + " = ?"; String[] emailSelection = new String[] { contactId, android.provider.ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE, }; int resultId5 = context.getContentResolver().update( android.provider.ContactsContract.Data.CONTENT_URI, values, emailWhere, emailSelection); isModify = true; } if (cursor != null) cursor.close(); try { Cursor cusor = null; projection = new String[] { android.provider.Contacts.People._ID, android.provider.Contacts.People.NAME, android.provider.Contacts.People.NUMBER }; selection = android.provider.Contacts.People._ID + " = ? "; cusor = contentResolver.query(android.provider.Contacts.People.CONTENT_URI, projection, selection, selectionArgs, null); cusor.moveToFirst(); while (cusor.moveToNext()) { ContentValues values = new ContentValues(); String nameWhere = android.provider.Contacts.Phones.PERSON_ID + "=? "; values.put(android.provider.Contacts.People.NAME, inName); contentResolver.update(android.provider.Contacts.People.CONTENT_URI, values, nameWhere, selectionArgs); // ??type?????? values.clear(); values.put(android.provider.Contacts.Phones.TYPE, android.provider.Contacts.Phones.TYPE_MOBILE); values.put(android.provider.Contacts.Phones.NUMBER, inNum); String numWhere = android.provider.Contacts.Phones.PERSON_ID + "=? "; String[] numWhereParams = { contactId }; contentResolver.update(android.provider.Contacts.Phones.CONTENT_URI, values, numWhere, numWhereParams); // ?type????? values.clear(); values.put(android.provider.Contacts.ContactMethods.KIND, android.provider.Contacts.KIND_EMAIL); values.put(android.provider.Contacts.ContactMethods.DATA, inEmail); values.put(android.provider.Contacts.ContactMethods.TYPE, android.provider.Contacts.ContactMethods.TYPE_HOME); String emailWhere = android.provider.Contacts.ContactMethods.PERSON_ID + "=? "; String[] emailWhereParams = { contactId }; contentResolver.update(android.provider.Contacts.ContactMethods.CONTENT_URI, values, emailWhere, emailWhereParams); isModify = true; } if (cusor != null) cusor.close(); } catch (Exception e) { ToastShow(context, finder.getString(context, "plugin_contact_modify_fail")); return false; } } catch (Exception e) { ToastShow(context, finder.getString(context, "plugin_contact_modify_fail")); } } if (isModify) { ToastShow(context, finder.getString(context, "plugin_contact_modify_succeed")); } else { ToastShow(context, finder.getString(context, "plugin_contact_modify_fail")); } return isModify; }
From source file:com.android.messaging.datamodel.BugleDatabaseOperations.java
@DoesNotRunOnMainThread public static void updateMessageAndPartsInTransaction(final DatabaseWrapper dbWrapper, final MessageData message, final List<MessagePartData> partsToUpdate) { Assert.isNotMainThread();//from w ww. j a v a 2s. co m Assert.isTrue(dbWrapper.getDatabase().inTransaction()); final ContentValues values = new ContentValues(); for (final MessagePartData messagePart : partsToUpdate) { values.clear(); messagePart.populate(values); updatePartRowIfExists(dbWrapper, messagePart.getPartId(), values); } values.clear(); message.populate(values); updateMessageRowIfExists(dbWrapper, message.getMessageId(), values); }
From source file:com.sf.tracem.db.DBManager.java
public void updateOrders(List<Order> orders) { traceMwdb = toh.getWritableDatabase(); ContentValues values = new ContentValues(); for (Order order : orders) { values.clear(); values.put(Order.AUFNR, order.getAUFNR()); values.put(Order.AUFART, order.getAUFART()); values.put(Order.CO_GSTRP, order.getCO_GSTRP()); values.put(Order.AUFTEXT, order.getAUFTEXT()); values.put(Order.PARTNER, order.getPARTNER()); values.put(Partner.ADDRESS, order.getADDRESS()); values.put(Order.ORDER_STATUS, order.getORDER_STATUS()); values.put(Order.EXP_DAYS, order.getEXP_DAYS()); values.put(Order.EXP_STATUS, order.getEXP_STATUS()); values.put(Order.ZHOURS, order.getZHOURS()); // values.put(OrdersTable.ASSIGNED_STATUS, // order.getASSIGNED_STATUS()); // values.put(OrdersTable.ID_PROGRAM, order.getID_PROGRAM()); long result = traceMwdb.update(Order.TABLE_NAME, values, Order.AUFNR + " = ?", new String[] { order.getAUFNR() }); if (result != -1) { Log.i("Insert Order", "" + result); } else {/*from w w w. java 2s . c o m*/ Log.e("Insert Order", "" + result); } } }
From source file:com.yuntongxun.ecdemo.storage.IMessageSqlManager.java
/** * ???//w w w . j a va2 s . c om * * @param rowid * @param detail * @return */ public static int changeResendMsg(long rowid, ECMessage detail) { if (detail == null || TextUtils.isEmpty(detail.getMsgId()) || rowid == -1) { return -1; } String where = IMessageColumn.ID + "=" + rowid + " and " + IMessageColumn.SEND_STATUS + " = " + ECMessage.MessageStatus.FAILED.ordinal(); ContentValues values = null; try { values = new ContentValues(); values.put(IMessageColumn.MESSAGE_ID, detail.getMsgId()); values.put(IMessageColumn.SEND_STATUS, detail.getMsgStatus().ordinal()); values.put(IMessageColumn.USER_DATA, detail.getUserData()); return getInstance().sqliteDB().update(DatabaseHelper.TABLES_NAME_IM_MESSAGE, values, where, null); } catch (Exception e) { e.printStackTrace(); throw new SQLException(e.getMessage()); } finally { if (values != null) { values.clear(); values = null; } } }
From source file:com.sf.tracem.db.DBManager.java
/** * Insert orders in sqlite database/*www .java2s. c o m*/ * * @param orders */ public void insertOrders(List<Order> orders) { traceMwdb = toh.getWritableDatabase(); ContentValues values = new ContentValues(); for (Order order : orders) { values.clear(); if (order.getPARTNER() != null) { values.put(Partner.PARTNER, order.getPARTNER()); values.put(Partner.ADDRESS, order.getADDRESS()); long result = traceMwdb.insert(Partner.TABLE_NAME, null, values); if (result != -1) { Log.i("Insert Partner", "" + result); } else { Log.e("Insert Partner", "" + result); } } } for (Order order : orders) { values.clear(); values.put(Order.AUFNR, order.getAUFNR()); values.put(Order.AUFART, order.getAUFART()); values.put(Order.CO_GSTRP, order.getCO_GSTRP()); values.put(Order.AUFTEXT, order.getAUFTEXT()); if (order.getPARTNER() == null) { continue; } values.put(Order.PARTNER, order.getPARTNER()); values.put(Partner.ADDRESS, order.getADDRESS()); values.put(Order.ORDER_STATUS, order.getORDER_STATUS()); values.put(Order.EXP_DAYS, order.getEXP_DAYS()); values.put(Order.EXP_STATUS, order.getEXP_STATUS()); values.put(Order.ZHOURS, order.getZHOURS()); // values.put(OrdersTable.ASSIGNED_STATUS, // order.getASSIGNED_STATUS()); // values.put(OrdersTable.ID_PROGRAM, order.getID_PROGRAM()); long result = traceMwdb.insert(Order.TABLE_NAME, null, values); if (result != -1) { Log.i("Insert Order", "" + result); } else { Log.e("Insert Order", "" + result); } } }
From source file:com.yuntongxun.ecdemo.storage.IMessageSqlManager.java
/** * Im????//from w w w .j a v a 2s . com * * @param msgId ?ID * @param sendStatu ??? * @return */ public static int setIMessageSendStatus(String msgId, int sendStatu, int duration) { int row = 0; ContentValues values = new ContentValues(); try { String where = IMessageColumn.MESSAGE_ID + " = '" + msgId + "' and " + IMessageColumn.SEND_STATUS + "!=" + sendStatu; values.put(IMessageColumn.SEND_STATUS, sendStatu); if (duration > 0) { values.put(IMessageColumn.DURATION, duration); } row = getInstance().sqliteDB().update(DatabaseHelper.TABLES_NAME_IM_MESSAGE, values, where, null); // notifyChanged(msgId); } catch (Exception e) { LogUtil.e(TAG + " " + e.toString()); e.getStackTrace(); } finally { if (values != null) { values.clear(); values = null; } } return row; }