List of usage examples for android.content ContentValues putNull
public void putNull(String key)
From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java
@Override protected void onDestroy() { if (getIntent().getAction().equals(Intent.ACTION_EDIT)) { String url = mUrlEditText.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID, FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null); if (cursor.moveToFirst() && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) { cursor.close();/*from w w w.ja v a2 s . co m*/ Toast.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, Toast.LENGTH_LONG).show(); } else { cursor.close(); ContentValues values = new ContentValues(); if (!url.startsWith(Constants.HTTP) && !url.startsWith(Constants.HTTPS)) { url = Constants.HTTP + url; } values.put(FeedColumns.URL, url); String name = mNameEditText.getText().toString(); values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null); values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null); values.put(FeedColumns.FETCH_MODE, 0); values.putNull(FeedColumns.ERROR); cr.update(getIntent().getData(), values, null, null); if (!name.equals(mPreviousName)) { cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); cr.notifyChange(FeedColumns.GROUPED_FEEDS_CONTENT_URI, null); } } } super.onDestroy(); }
From source file:co.nerdart.ourss.activity.EditFeedActivity.java
@Override protected void onDestroy() { if (getIntent().getAction().equals(Intent.ACTION_EDIT)) { String url = mUrlEditText.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID, FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null); if (cursor.moveToFirst() && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) { cursor.close();/*from w w w . j av a 2s . co m*/ //Toast.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, // Toast.LENGTH_LONG).show(); Crouton.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, Style.INFO); } else { cursor.close(); ContentValues values = new ContentValues(); if (!url.startsWith(Constants.HTTP) && !url.startsWith(Constants.HTTPS)) { url = Constants.HTTP + url; } values.put(FeedColumns.URL, url); String name = mNameEditText.getText().toString(); values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null); values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null); values.put(FeedColumns.FETCH_MODE, 0); values.putNull(FeedColumns.ERROR); cr.update(getIntent().getData(), values, null, null); if (!name.equals(mPreviousName)) { cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); } } } super.onDestroy(); }
From source file:org.runnerup.export.SyncManager.java
void resetDB(final Callback callback, final Synchronizer synchronizer, final boolean clearUploads) { final String args[] = { Long.toString(synchronizer.getId()) }; ContentValues config = new ContentValues(); config.putNull(DB.ACCOUNT.AUTH_CONFIG); mDB.update(DB.ACCOUNT.TABLE, config, "_id = ?", args); if (clearUploads) { mDB.delete(DB.EXPORT.TABLE, DB.EXPORT.ACCOUNT + " = ?", args); }/*ww w . j a v a 2 s . c o m*/ synchronizer.reset(); callback.run(synchronizer.getName(), Synchronizer.Status.OK); }
From source file:com.android.email.mail.store.zx.LocalStore.java
/** * Deletes all cached attachments for the entire store. */// w w w. j ava 2 s. c o m public void pruneCachedAttachments() throws MessagingException { File[] files = mAttachmentsDir.listFiles(); for (File file : files) { if (file.exists()) { try { Cursor cursor = null; try { cursor = mDb.query("attachments", new String[] { "store_data" }, "id = ?", new String[] { file.getName() }, null, null, null); if (cursor.moveToNext()) { if (cursor.getString(0) == null) { /* * If the attachment has no store data it is not recoverable, so * we won't delete it. */ continue; } } } finally { if (cursor != null) { cursor.close(); } } ContentValues cv = new ContentValues(); cv.putNull("content_uri"); mDb.update("attachments", cv, "id = ?", new String[] { file.getName() }); } catch (Exception e) { /* * If the row has gone away before we got to mark it not-downloaded that's * okay. */ } if (!file.delete()) { file.deleteOnExit(); } } } }
From source file:net.fred.feedex.activity.EditFeedActivity.java
@Override protected void onDestroy() { if (getIntent().getAction().equals(Intent.ACTION_EDIT)) { String url = mUrlEditText.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = null;/* www . java 2 s.co m*/ try { cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID, FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null); if (cursor != null && cursor.moveToFirst() && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) { UiUtils.showMessage(EditFeedActivity.this, R.string.error_feed_url_exists); } else { ContentValues values = new ContentValues(); if (!url.startsWith(Constants.HTTP_SCHEME) && !url.startsWith(Constants.HTTPS_SCHEME)) { url = Constants.HTTP_SCHEME + url; } values.put(FeedColumns.URL, url); String name = mNameEditText.getText().toString(); values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null); values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null); values.put(FeedColumns.FETCH_MODE, 0); values.putNull(FeedColumns.ERROR); cr.update(getIntent().getData(), values, null, null); } } catch (Exception ignored) { } finally { if (cursor != null) { cursor.close(); } } } super.onDestroy(); }
From source file:com.app.uafeed.activity.EditFeedActivity.java
@Override protected void onDestroy() { if (getIntent().getAction().equals(Intent.ACTION_EDIT)) { String url = mUrlEditText.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID, FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null); if (cursor.moveToFirst() && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) { cursor.close();//w ww . j a v a 2 s.c o m Toast.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, Toast.LENGTH_LONG).show(); } else { cursor.close(); ContentValues values = new ContentValues(); if (!url.startsWith(Constants.HTTP_SCHEME) && !url.startsWith(Constants.HTTPS_SCHEME)) { url = Constants.HTTP_SCHEME + url; } values.put(FeedColumns.URL, url); String name = mNameEditText.getText().toString(); values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null); values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null); values.put(FeedColumns.FETCH_MODE, 0); values.putNull(FeedColumns.ERROR); cr.update(getIntent().getData(), values, null, null); } } super.onDestroy(); }
From source file:com.carlrice.reader.activity.EditFeedActivity.java
@Override protected void onDestroy() { if (getIntent().getAction().equals(Intent.ACTION_EDIT)) { String url = mUrlEditText.getText().toString(); ContentResolver cr = getContentResolver(); Cursor cursor = null;/* w w w .j a v a 2 s . c o m*/ try { cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID, FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null); if (cursor != null && cursor.moveToFirst() && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) { Toast.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, Toast.LENGTH_LONG).show(); } else { ContentValues values = new ContentValues(); if (!url.startsWith(Constants.HTTP_SCHEME) && !url.startsWith(Constants.HTTPS_SCHEME)) { url = Constants.HTTP_SCHEME + url; } values.put(FeedColumns.URL, url); String name = mNameEditText.getText().toString(); values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null); values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null); values.put(FeedColumns.FETCH_MODE, 0); values.putNull(FeedColumns.ERROR); cr.update(getIntent().getData(), values, null, null); } } catch (Exception ignored) { } finally { if (cursor != null) { cursor.close(); } } } super.onDestroy(); }
From source file:com.android.email.mail.store.LocalStore.java
/** * Deletes all cached attachments for the entire store. */// www . ja v a2s . com public int pruneCachedAttachments() throws MessagingException { int prunedCount = 0; File[] files = mAttachmentsDir.listFiles(); for (File file : files) { if (file.exists()) { try { Cursor cursor = null; try { cursor = mDb.query("attachments", new String[] { "store_data" }, "id = ?", new String[] { file.getName() }, null, null, null); if (cursor.moveToNext()) { if (cursor.getString(0) == null) { /* * If the attachment has no store data it is not recoverable, so * we won't delete it. */ continue; } } } finally { if (cursor != null) { cursor.close(); } } ContentValues cv = new ContentValues(); cv.putNull("content_uri"); mDb.update("attachments", cv, "id = ?", new String[] { file.getName() }); } catch (Exception e) { /* * If the row has gone away before we got to mark it not-downloaded that's * okay. */ } if (!file.delete()) { file.deleteOnExit(); } prunedCount++; } } return prunedCount; }
From source file:com.ziyou.selftravel.download.DownloadManager.java
/** * Restart the given downloads, which must have already completed * (successfully or not). This method will only work when called from within * the download manager's process.//from ww w . j a va 2 s .c o m * * @param ids the IDs of the downloads * @hide */ public void restartDownload(long... ids) { Cursor cursor = query(new Query().setFilterById(ids)); try { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { int status = cursor.getInt(cursor.getColumnIndex(COLUMN_STATUS)); if (status != STATUS_SUCCESSFUL && status != STATUS_FAILED) { throw new IllegalArgumentException("Cannot restart incomplete download: " + cursor.getLong(cursor.getColumnIndex(COLUMN_ID))); } } } finally { cursor.close(); } ContentValues values = new ContentValues(); values.put(Downloads.Impl.COLUMN_CURRENT_BYTES, 0); values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, -1); values.putNull(Downloads.Impl._DATA); values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_PENDING); values.put(Downloads.Impl.COLUMN_FAILED_CONNECTIONS, 0); mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids)); }
From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java
public void clearEncoded(long id) { ContentValues cv = new ContentValues(); cv.putNull(DbObject.ENCODED); getWritableDatabase().update(DbObject.TABLE, cv, DbObject._ID + " = ?", new String[] { String.valueOf(id) }); }