Here are the examples of the java api android.content.ContentValues taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3818 Examples
19
Source : ConversationDetailActivity.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
@Override
protected void onPause() {
super.onPause();
mConvoView.setSelected(false);
// unregisterReceiver(receiver);
// Set last read date now!
if (mChatId != -1) {
ContentValues values = new ContentValues(1);
values.put(Imps.Chats.LAST_READ_DATE, System.currentTimeMillis());
getContentResolver().update(ContentUris.withAppendedId(Imps.Chats.CONTENT_URI, mChatId), values, null, null);
}
}
19
Source : ConversationDetailActivity.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
processIntent(intent);
// Set last read date now!
if (mChatId != -1) {
ContentValues values = new ContentValues(1);
values.put(Imps.Chats.LAST_READ_DATE, System.currentTimeMillis());
getContentResolver().update(ContentUris.withAppendedId(Imps.Chats.CONTENT_URI, mChatId), values, null, null);
}
}
19
Source : ConversationDetailActivity.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
private void setLastRead() {
// Set last read date now!
if (mChatId != -1) {
ContentValues values = new ContentValues(1);
values.put(Imps.Chats.LAST_READ_DATE, System.currentTimeMillis());
getContentResolver().update(ContentUris.withAppendedId(Imps.Chats.CONTENT_URI, mChatId), values, null, null);
}
}
19
Source : AccountViewFragment.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
void signOut() {
// if you are signing out, then we will deactive "auto" sign in
ContentValues values = new ContentValues();
values.put(Imps.AccountColumns.KEEP_SIGNED_IN, 0);
getActivity().getContentResolver().update(mAccountUri, values, null, null);
mApp = (ImApp) getActivity().getApplication();
mApp.callWhenServiceConnected(mHandler, new Runnable() {
@Override
public void run() {
signOut(mProviderId, mAccountId);
}
});
}
19
Source : AccountViewFragment.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
void createNewaccount(long accountId) {
ContentValues values = new ContentValues(2);
values.put(Imps.AccountStatusColumns.PRESENCE_STATUS, Imps.CommonPresenceColumns.NEW_ACCOUNT);
values.put(Imps.AccountStatusColumns.CONNECTION_STATUS, Imps.ConnectionStatus.OFFLINE);
String where = Imps.AccountStatusColumns.ACCOUNT + "=?";
getActivity().getContentResolver().update(Imps.AccountStatus.CONTENT_URI, values, where, new String[] { Long.toString(accountId) });
}
19
Source : AccountViewFragment.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
private void setAccountKeepSignedIn(final boolean rememberPreplaced) {
ContentValues values = new ContentValues();
values.put(Imps.AccountColumns.KEEP_SIGNED_IN, rememberPreplaced ? 1 : 0);
getActivity().getContentResolver().update(mAccountUri, values, null, null);
}
19
Source : AccountFragment.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
void signOut() {
// if you are signing out, then we will deactive "auto" sign in
ContentValues values = new ContentValues();
values.put(Imps.AccountColumns.KEEP_SIGNED_IN, 0);
getActivity().getContentResolver().update(ContentUris.withAppendedId(Imps.Account.CONTENT_URI, mAccountId), values, null, null);
signOut(mProviderId, mAccountId);
;
}
19
Source : AccountActivity.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
void signOut() {
// if you are signing out, then we will deactive "auto" sign in
ContentValues values = new ContentValues();
values.put(Imps.AccountColumns.KEEP_SIGNED_IN, 0);
getContentResolver().update(mAccountUri, values, null, null);
mApp = (ImApp) getApplication();
mApp.callWhenServiceConnected(mHandler, new Runnable() {
@Override
public void run() {
signOut(mProviderId, mAccountId);
}
});
}
19
Source : AccountActivity.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
private void setAccountKeepSignedIn(final boolean rememberPreplaced) {
ContentValues values = new ContentValues();
values.put(Imps.AccountColumns.KEEP_SIGNED_IN, rememberPreplaced ? 1 : 0);
getContentResolver().update(mAccountUri, values, null, null);
}
19
Source : AccountActivity.java
with Apache License 2.0
from zom
with Apache License 2.0
from zom
void createNewaccount(long accountId) {
ContentValues values = new ContentValues(2);
values.put(Imps.AccountStatusColumns.PRESENCE_STATUS, Imps.CommonPresenceColumns.NEW_ACCOUNT);
values.put(Imps.AccountStatusColumns.CONNECTION_STATUS, Imps.ConnectionStatus.OFFLINE);
String where = Imps.AccountStatusColumns.ACCOUNT + "=?";
getContentResolver().update(Imps.AccountStatus.CONTENT_URI, values, where, new String[] { Long.toString(accountId) });
}
19
Source : HabitDAO.java
with GNU General Public License v3.0
from ywwynm
with GNU General Public License v3.0
from ywwynm
public void updateRecordOfHabit(long id, String record) {
ContentValues values = new ContentValues();
values.put(Def.Database.COLUMN_RECORD_HABITS, record);
db.update(Def.Database.TABLE_HABITS, values, "id=" + id, null);
}
19
Source : HabitDAO.java
with GNU General Public License v3.0
from ywwynm
with GNU General Public License v3.0
from ywwynm
public void removeLastHabitIntervalInfo(long id) {
String interval = getHabitById(id).getIntervalInfo();
interval = interval.substring(0, interval.lastIndexOf(interval.endsWith(";") ? "," : ";") + 1);
ContentValues values = new ContentValues();
values.put(Def.Database.COLUMN_INTERVAL_INFO_HABITS, interval);
db.update(Def.Database.TABLE_HABITS, values, "id=" + id, null);
}
19
Source : HabitDAO.java
with GNU General Public License v3.0
from ywwynm
with GNU General Public License v3.0
from ywwynm
public void updateHabitRemindedTimes(long id, long remindedTimes) {
ContentValues values = new ContentValues();
values.put(Def.Database.COLUMN_REMINDED_TIMES_HABITS, remindedTimes);
db.update(Def.Database.TABLE_HABITS, values, "id=" + id, null);
}
19
Source : HabitDAO.java
with GNU General Public License v3.0
from ywwynm
with GNU General Public License v3.0
from ywwynm
public void updateHabitReminder(long hrId, long notifyTime) {
ContentValues values = new ContentValues();
values.put(Def.Database.COLUMN_NOTIFY_TIME_HABIT_REMINDERS, notifyTime);
db.update(Def.Database.TABLE_HABIT_REMINDERS, values, "id=" + hrId, null);
AlarmHelper.setHabitReminderAlarm(mContext, hrId, notifyTime);
}
19
Source : HabitDAO.java
with GNU General Public License v3.0
from ywwynm
with GNU General Public License v3.0
from ywwynm
public void addHabitIntervalInfo(long id, String intervalInfoToAdd) {
ContentValues values = new ContentValues();
values.put(Def.Database.COLUMN_INTERVAL_INFO_HABITS, getHabitById(id).getIntervalInfo() + intervalInfoToAdd);
db.update(Def.Database.TABLE_HABITS, values, "id=" + id, null);
}
19
Source : Fragment_home.java
with Apache License 2.0
from yangxch
with Apache License 2.0
from yangxch
/**
* 根据foodId更新当前本地数据库中的这条记录,使用LitePal
* (把Foods表中id为item.getId()的记录的count改成item.count)
*/
private void updateSelectedFoodsList(Foods item) {
ContentValues values = new ContentValues();
values.put("count", item.count);
DataSupport.update(Foods.clreplaced, values, item.getId());
}
19
Source : OC_FatController.java
with Apache License 2.0
from XPRIZE
with Apache License 2.0
from XPRIZE
public void saveStarInDB(DBSQL db, int userid, long unitid, String colour) {
ContentValues contentValues = new ContentValues();
contentValues.put("userid", userid);
contentValues.put("unitid", unitid);
contentValues.put("colour", colour);
boolean result = db.doReplaceOnTable(DBSQL.TABLE_STARS, contentValues) > 0;
}
19
Source : MlUnitInstance.java
with Apache License 2.0
from XPRIZE
with Apache License 2.0
from XPRIZE
public Boolean saveToDB(DBSQL db) {
ContentValues contentValues = getContentValues(null, intFields, longFields, floatFields);
boolean result = db.doInsertOnTable(DBSQL.TABLE_UNIT_INSTANCES, contentValues) > 0;
return result;
}
19
Source : DBSQL.java
with Apache License 2.0
from XPRIZE
with Apache License 2.0
from XPRIZE
public long doUpdateOnTable(String table, Map<String, String> whereMap, ContentValues updateValues) {
long result = database.update(table, updateValues, mapToWhereStatement(whereMap), mapToWhereValues(whereMap));
return result;
}
19
Source : DBSQL.java
with Apache License 2.0
from XPRIZE
with Apache License 2.0
from XPRIZE
public long doInsertOnTable(String table, ContentValues insertValues) {
long rowId = database.insert(table, null, insertValues);
return rowId;
}
19
Source : DBSQL.java
with Apache License 2.0
from XPRIZE
with Apache License 2.0
from XPRIZE
public long doReplaceOnTable(String table, ContentValues insertValues) {
long rowId = database.replace(table, null, insertValues);
return rowId;
}
19
Source : BookmarkDatabase.java
with GNU General Public License v3.0
from XndroidDev
with GNU General Public License v3.0
from XndroidDev
/**
* Updates a bookmark in the database with the provided URL. If it
* cannot find any bookmark with the given URL, it will try to update
* a bookmark with the {@link #alternateSlashUrl(String)} as its URL.
*
* @param url the URL to update.
* @param contentValues the new values to update to.
* @return the numebr of rows updated.
*/
private int updateWithOptionalEndSlash(@NonNull String url, @NonNull ContentValues contentValues) {
int updatedRows = lazyDatabase().update(TABLE_BOOKMARK, contentValues, KEY_URL + "=?", new String[] { url });
if (updatedRows == 0) {
String alternateUrl = alternateSlashUrl(url);
updatedRows = lazyDatabase().update(TABLE_BOOKMARK, contentValues, KEY_URL + "=?", new String[] { alternateUrl });
}
return updatedRows;
}
19
Source : Whitelist.java
with Apache License 2.0
from xietiantian
with Apache License 2.0
from xietiantian
/**
* A Whitelist record from our database
*/
public clreplaced Whitelist {
boolean isNew = true;
private ContentValues content;
public Whitelist() {
content = new ContentValues();
// default: do NOT record
content.put(Database.WHITELIST_TABLE_RECORD, false);
}
public String getContactId() {
return content.getreplacedtring(Database.WHITELIST_TABLE_CONTACT_ID);
}
public void setContactId(String contactId) {
content.put(Database.WHITELIST_TABLE_CONTACT_ID, contactId);
}
public boolean isRecordable() {
return content.getAsBoolean(Database.WHITELIST_TABLE_RECORD);
}
public void setRecordable(boolean enable) {
content.put(Database.WHITELIST_TABLE_RECORD, enable);
}
public int getId() {
return content.getAsInteger(Database.WHITELIST_TABLE_ID);
}
public ContentValues getContent() {
return content;
}
}
19
Source : CallLog.java
with Apache License 2.0
from xietiantian
with Apache License 2.0
from xietiantian
/**
* A Call Log record from our database
*/
public clreplaced CallLog {
static final int VERSION = 1;
boolean isNew = true;
public ContentValues getContent() {
return content;
}
private ContentValues content;
public CallLog() {
content = new ContentValues();
// default "outgoing" false (therefore incoming)
content.put(Database.CALL_RECORDS_TABLE_OUTGOING, false);
// default "keep" false (therefore allow automatic deletion)
content.put(Database.CALL_RECORDS_TABLE_KEEP, false);
}
public CallLog(ContentValues content) {
this.content = content;
}
public String getPhoneNumber() {
String phone = content.getreplacedtring(Database.CALL_RECORDS_TABLE_PHONE_NUMBER);
if (null == phone)
return "";
return phone;
}
public void setPhoneNumber(String phoneNumer) {
content.put(Database.CALL_RECORDS_TABLE_PHONE_NUMBER, phoneNumer);
}
public int getId() {
return content.getAsInteger(Database.CALL_RECORDS_TABLE_ID);
}
public boolean isOutgoing() {
// Outgoing is "true" Incoming is "false"
return content.getAsBoolean(Database.CALL_RECORDS_TABLE_OUTGOING);
}
public void setOutgoing() {
content.put(Database.CALL_RECORDS_TABLE_OUTGOING, true);
}
public Calendar getStartTime() {
Long time = content.getAsLong(Database.CALL_RECORDS_TABLE_START_DATE);
Calendar cal = GregorianCalendar.getInstance();
if (null != time)
cal.setTimeInMillis(time);
return cal;
}
public void setSartTime(Calendar cal) {
content.put(Database.CALL_RECORDS_TABLE_START_DATE, cal.getTimeInMillis());
}
public Calendar getEndTime() {
Long time = content.getAsLong(Database.CALL_RECORDS_TABLE_END_DATE);
Calendar cal = GregorianCalendar.getInstance();
if (null != time)
cal.setTimeInMillis(time);
return cal;
}
public void setEndTime(Calendar cal) {
content.put(Database.CALL_RECORDS_TABLE_END_DATE, cal.getTimeInMillis());
}
public String getPathToRecording() {
String path = content.getreplacedtring(Database.CALL_RECORDS_TABLE_RECORDING_PATH);
if (path == null)
return "";
return path;
}
public void setPathToRecording(String path) {
content.put(Database.CALL_RECORDS_TABLE_RECORDING_PATH, path);
}
public boolean isKept() {
Boolean asBoolean = content.getAsBoolean(Database.CALL_RECORDS_TABLE_KEEP);
if (null == asBoolean)
return false;
return asBoolean;
}
public void setKept(boolean keep) {
content.put(Database.CALL_RECORDS_TABLE_KEEP, keep);
}
public void save(Context context) {
Database.getInstance(context).addCall(this);
}
}
19
Source : ContentValuesBuilder.java
with GNU General Public License v3.0
from XecureIT
with GNU General Public License v3.0
from XecureIT
public clreplaced ContentValuesBuilder {
private final ContentValues contentValues;
public ContentValuesBuilder(ContentValues contentValues) {
this.contentValues = contentValues;
}
public void add(String key, String charsetKey, EncodedStringValue value) {
if (value != null) {
contentValues.put(key, Util.toIsoString(value.getTextString()));
contentValues.put(charsetKey, value.getCharacterSet());
}
}
public void add(String contentKey, byte[] value) {
if (value != null) {
contentValues.put(contentKey, Util.toIsoString(value));
}
}
public void add(String contentKey, int b) {
if (b != 0)
contentValues.put(contentKey, b);
}
public void add(String contentKey, long value) {
if (value != -1L)
contentValues.put(contentKey, value);
}
public ContentValues getContentValues() {
return contentValues;
}
}
19
Source : AddRowFragment.java
with Apache License 2.0
from whataa
with Apache License 2.0
from whataa
private void insert(final ContentValues values) {
showLoading();
new SimpleTask<>(new SimpleTask.Callback<Void, DatabaseResult>() {
@Override
public DatabaseResult doInBackground(Void[] params) {
return Pandora.get().getDatabases().insert(key, table, values);
}
@Override
public void onPostExecute(DatabaseResult result) {
hideLoading();
if (result.sqlError == null) {
Utils.toast(R.string.pd_success);
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, null);
} else {
Utils.toast(result.sqlError.message);
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_CANCELED, null);
}
}
}).execute();
}
19
Source : BaseDao.java
with MIT License
from wangcantian
with MIT License
from wangcantian
/**
* 根据条件更新行 *
*/
public boolean updateData(T data, String whereClause, String whereArgs) {
boolean ret = false;
if (data != null) {
ContentValues values = getContentValuesByData(data);
if (mDBHelper.getWritableDatabase().update(getTableName(), values, whereClause == null ? null : whereClause + "=?", new String[] { whereArgs }) > 0) {
ret = true;
} else {
ret = false;
}
}
return ret;
}
19
Source : MusicPlayer.java
with GNU General Public License v3.0
from Vinetos
with GNU General Public License v3.0
from Vinetos
public clreplaced MusicPlayer {
private static final WeakHashMap<Context, ServiceBinder> mConnectionMap;
private static final long[] sEmptyList;
public static ITimberService mService = null;
private static ContentValues[] mContentValuesCache = null;
static {
mConnectionMap = new WeakHashMap<Context, ServiceBinder>();
sEmptyList = new long[0];
}
public static final ServiceToken bindToService(final Context context, final ServiceConnection callback) {
Activity realActivity = ((Activity) context).getParent();
if (realActivity == null) {
realActivity = (Activity) context;
}
final ContextWrapper contextWrapper = new ContextWrapper(realActivity);
contextWrapper.startService(new Intent(contextWrapper, MusicService.clreplaced));
final ServiceBinder binder = new ServiceBinder(callback, contextWrapper.getApplicationContext());
if (contextWrapper.bindService(new Intent().setClreplaced(contextWrapper, MusicService.clreplaced), binder, 0)) {
mConnectionMap.put(contextWrapper, binder);
return new ServiceToken(contextWrapper);
}
return null;
}
public static void unbindFromService(final ServiceToken token) {
if (token == null) {
return;
}
final ContextWrapper mContextWrapper = token.mWrappedContext;
final ServiceBinder mBinder = mConnectionMap.remove(mContextWrapper);
if (mBinder == null) {
return;
}
mContextWrapper.unbindService(mBinder);
if (mConnectionMap.isEmpty()) {
mService = null;
}
}
public static final boolean isPlaybackServiceConnected() {
return mService != null;
}
public static void next() {
try {
if (mService != null) {
mService.next();
}
} catch (final RemoteException ignored) {
}
}
public static void initPlaybackServiceWithSettings(final Context context) {
}
public static void asyncNext(final Context context) {
final Intent previous = new Intent(context, MusicService.clreplaced);
previous.setAction(MusicService.NEXT_ACTION);
context.startService(previous);
}
public static void previous(final Context context, final boolean force) {
final Intent previous = new Intent(context, MusicService.clreplaced);
if (force) {
previous.setAction(MusicService.PREVIOUS_FORCE_ACTION);
} else {
previous.setAction(MusicService.PREVIOUS_ACTION);
}
context.startService(previous);
}
public static void playOrPause() {
try {
if (mService != null) {
if (mService.isPlaying()) {
mService.pause();
} else {
mService.play();
}
}
} catch (final Exception ignored) {
}
}
public static void cycleRepeat() {
try {
if (mService != null) {
switch(mService.getRepeatMode()) {
case MusicService.REPEAT_NONE:
mService.setRepeatMode(MusicService.REPEAT_ALL);
break;
case MusicService.REPEAT_ALL:
mService.setRepeatMode(MusicService.REPEAT_CURRENT);
if (mService.getShuffleMode() != MusicService.SHUFFLE_NONE) {
mService.setShuffleMode(MusicService.SHUFFLE_NONE);
}
break;
default:
mService.setRepeatMode(MusicService.REPEAT_NONE);
break;
}
}
} catch (final RemoteException ignored) {
}
}
public static void cycleShuffle() {
try {
if (mService != null) {
switch(mService.getShuffleMode()) {
case MusicService.SHUFFLE_NONE:
mService.setShuffleMode(MusicService.SHUFFLE_NORMAL);
if (mService.getRepeatMode() == MusicService.REPEAT_CURRENT) {
mService.setRepeatMode(MusicService.REPEAT_ALL);
}
break;
case MusicService.SHUFFLE_NORMAL:
mService.setShuffleMode(MusicService.SHUFFLE_NONE);
break;
case MusicService.SHUFFLE_AUTO:
mService.setShuffleMode(MusicService.SHUFFLE_NONE);
break;
default:
break;
}
}
} catch (final RemoteException ignored) {
}
}
public static final boolean isPlaying() {
if (mService != null) {
try {
return mService.isPlaying();
} catch (final RemoteException ignored) {
}
}
return false;
}
public static final int getShuffleMode() {
if (mService != null) {
try {
return mService.getShuffleMode();
} catch (final RemoteException ignored) {
}
}
return 0;
}
public static void setShuffleMode(int mode) {
try {
if (mService != null) {
mService.setShuffleMode(mode);
}
} catch (RemoteException ignored) {
}
}
public static final int getRepeatMode() {
if (mService != null) {
try {
return mService.getRepeatMode();
} catch (final RemoteException ignored) {
}
}
return 0;
}
public static final String getTrackName() {
if (mService != null) {
try {
return mService.getTrackName();
} catch (final RemoteException ignored) {
}
}
return null;
}
public static final String getArtistName() {
if (mService != null) {
try {
return mService.getArtistName();
} catch (final RemoteException ignored) {
}
}
return null;
}
public static final String getAlbumName() {
if (mService != null) {
try {
return mService.getAlbumName();
} catch (final RemoteException ignored) {
}
}
return null;
}
public static final long getCurrentAlbumId() {
if (mService != null) {
try {
return mService.getAlbumId();
} catch (final RemoteException ignored) {
}
}
return -1;
}
public static final long getCurrentAudioId() {
if (mService != null) {
try {
return mService.getAudioId();
} catch (final RemoteException ignored) {
}
}
return -1;
}
public static final MusicPlaybackTrack getCurrentTrack() {
if (mService != null) {
try {
return mService.getCurrentTrack();
} catch (final RemoteException ignored) {
}
}
return null;
}
public static final MusicPlaybackTrack getTrack(int index) {
if (mService != null) {
try {
return mService.getTrack(index);
} catch (final RemoteException ignored) {
}
}
return null;
}
public static final long getNextAudioId() {
if (mService != null) {
try {
return mService.getNextAudioId();
} catch (final RemoteException ignored) {
}
}
return -1;
}
public static final long getPreviousAudioId() {
if (mService != null) {
try {
return mService.getPreviousAudioId();
} catch (final RemoteException ignored) {
}
}
return -1;
}
public static final long getCurrentArtistId() {
if (mService != null) {
try {
return mService.getArtistId();
} catch (final RemoteException ignored) {
}
}
return -1;
}
public static final int getAudioSessionId() {
if (mService != null) {
try {
return mService.getAudioSessionId();
} catch (final RemoteException ignored) {
}
}
return -1;
}
public static final long[] getQueue() {
try {
if (mService != null) {
return mService.getQueue();
} else {
}
} catch (final RemoteException ignored) {
}
return sEmptyList;
}
public static final long getQueueItemAtPosition(int position) {
try {
if (mService != null) {
return mService.getQueueItemAtPosition(position);
} else {
}
} catch (final RemoteException ignored) {
}
return -1;
}
public static final int getQueueSize() {
try {
if (mService != null) {
return mService.getQueueSize();
} else {
}
} catch (final RemoteException ignored) {
}
return 0;
}
public static final int getQueuePosition() {
try {
if (mService != null) {
return mService.getQueuePosition();
}
} catch (final RemoteException ignored) {
}
return 0;
}
public static void setQueuePosition(final int position) {
if (mService != null) {
try {
mService.setQueuePosition(position);
} catch (final RemoteException ignored) {
}
}
}
public static void refresh() {
try {
if (mService != null) {
mService.refresh();
}
} catch (final RemoteException ignored) {
}
}
public static final int getQueueHistorySize() {
if (mService != null) {
try {
return mService.getQueueHistorySize();
} catch (final RemoteException ignored) {
}
}
return 0;
}
public static final int getQueueHistoryPosition(int position) {
if (mService != null) {
try {
return mService.getQueueHistoryPosition(position);
} catch (final RemoteException ignored) {
}
}
return -1;
}
public static final int[] getQueueHistoryList() {
if (mService != null) {
try {
return mService.getQueueHistoryList();
} catch (final RemoteException ignored) {
}
}
return null;
}
public static final int removeTrack(final long id) {
try {
if (mService != null) {
return mService.removeTrack(id);
}
} catch (final RemoteException ingored) {
}
return 0;
}
public static final boolean removeTrackAtPosition(final long id, final int position) {
try {
if (mService != null) {
return mService.removeTrackAtPosition(id, position);
}
} catch (final RemoteException ingored) {
}
return false;
}
public static void moveQueueItem(final int from, final int to) {
try {
if (mService != null) {
mService.moveQueueItem(from, to);
} else {
}
} catch (final RemoteException ignored) {
}
}
public static void playArtist(final Context context, final long artistId, int position, boolean shuffle) {
final long[] artistList = getSongListForArtist(context, artistId);
if (artistList != null) {
playAll(context, artistList, position, artistId, IdType.Artist, shuffle);
}
}
public static void playAlbum(final Context context, final long albumId, int position, boolean shuffle) {
final long[] albumList = getSongListForAlbum(context, albumId);
if (albumList != null) {
playAll(context, albumList, position, albumId, IdType.Album, shuffle);
}
}
public static void playAll(final Context context, final long[] list, int position, final long sourceId, final IdType sourceType, final boolean forceShuffle) {
if (list == null || list.length == 0 || mService == null) {
return;
}
try {
if (forceShuffle) {
mService.setShuffleMode(MusicService.SHUFFLE_NORMAL);
}
final long currentId = mService.getAudioId();
final int currentQueuePosition = getQueuePosition();
if (position != -1 && currentQueuePosition == position && currentId == list[position]) {
final long[] playlist = getQueue();
if (Arrays.equals(list, playlist)) {
mService.play();
return;
}
}
if (position < 0) {
position = 0;
}
mService.open(list, forceShuffle ? -1 : position, sourceId, sourceType.mId);
mService.play();
} catch (final RemoteException ignored) {
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
public static void playNext(Context context, final long[] list, final long sourceId, final IdType sourceType) {
if (mService == null) {
return;
}
try {
mService.enqueue(list, MusicService.NEXT, sourceId, sourceType.mId);
final String message = makeLabel(context, R.plurals.NNNtrackstoqueue, list.length);
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
} catch (final RemoteException ignored) {
}
}
public static void shuffleAll(final Context context) {
Cursor cursor = SongLoader.makeSongCursor(context, null, null);
final long[] trackList = SongLoader.getSongListForCursor(cursor);
if (trackList.length == 0 || mService == null) {
return;
}
try {
mService.setShuffleMode(MusicService.SHUFFLE_NORMAL);
if (getQueuePosition() == 0 && mService.getAudioId() == trackList[0] && Arrays.equals(trackList, getQueue())) {
mService.play();
return;
}
mService.open(trackList, -1, -1, IdType.NA.mId);
mService.play();
cursor.close();
} catch (final RemoteException ignored) {
}
}
public static final long[] getSongListForArtist(final Context context, final long id) {
final String[] projection = new String[] { BaseColumns._ID };
final String selection = MediaStore.Audio.AudioColumns.ARTIST_ID + "=" + id + " AND " + MediaStore.Audio.AudioColumns.IS_MUSIC + "=1";
Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null, MediaStore.Audio.AudioColumns.ALBUM_KEY + "," + MediaStore.Audio.AudioColumns.TRACK);
if (cursor != null) {
final long[] mList = SongLoader.getSongListForCursor(cursor);
cursor.close();
cursor = null;
return mList;
}
return sEmptyList;
}
public static final long[] getSongListForAlbum(final Context context, final long id) {
final String[] projection = new String[] { BaseColumns._ID };
final String selection = MediaStore.Audio.AudioColumns.ALBUM_ID + "=" + id + " AND " + MediaStore.Audio.AudioColumns.IS_MUSIC + "=1";
Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null, MediaStore.Audio.AudioColumns.TRACK + ", " + MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
if (cursor != null) {
final long[] mList = SongLoader.getSongListForCursor(cursor);
cursor.close();
cursor = null;
return mList;
}
return sEmptyList;
}
public static final int getSongCountForAlbumInt(final Context context, final long id) {
int songCount = 0;
if (id == -1) {
return songCount;
}
Uri uri = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, id);
Cursor cursor = context.getContentResolver().query(uri, new String[] { MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS }, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
if (!cursor.isNull(0)) {
songCount = cursor.getInt(0);
}
}
cursor.close();
cursor = null;
}
return songCount;
}
public static final String getReleaseDateForAlbum(final Context context, final long id) {
if (id == -1) {
return null;
}
Uri uri = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, id);
Cursor cursor = context.getContentResolver().query(uri, new String[] { MediaStore.Audio.AlbumColumns.FIRST_YEAR }, null, null, null);
String releaseDate = null;
if (cursor != null) {
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
releaseDate = cursor.getString(0);
}
cursor.close();
cursor = null;
}
return releaseDate;
}
public static void seek(final long position) {
if (mService != null) {
try {
mService.seek(position);
} catch (final RemoteException ignored) {
} catch (IllegalStateException ignored) {
}
}
}
public static void seekRelative(final long deltaInMs) {
if (mService != null) {
try {
mService.seekRelative(deltaInMs);
} catch (final RemoteException ignored) {
} catch (final IllegalStateException ignored) {
}
}
}
public static final long position() {
if (mService != null) {
try {
return mService.position();
} catch (final RemoteException ignored) {
} catch (final IllegalStateException ex) {
}
}
return 0;
}
public static final long duration() {
if (mService != null) {
try {
return mService.duration();
} catch (final RemoteException ignored) {
} catch (final IllegalStateException ignored) {
}
}
return 0;
}
public static void clearQueue() {
if (mService != null) {
try {
mService.removeTracks(0, Integer.MAX_VALUE);
} catch (final RemoteException ignored) {
}
}
}
public static void addToQueue(final Context context, final long[] list, long sourceId, IdType sourceType) {
if (mService == null) {
return;
}
try {
mService.enqueue(list, MusicService.LAST, sourceId, sourceType.mId);
final String message = makeLabel(context, R.plurals.NNNtrackstoqueue, list.length);
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
} catch (final RemoteException ignored) {
}
}
public static final String makeLabel(final Context context, final int pluralInt, final int number) {
return context.getResources().getQuanreplacedyString(pluralInt, number, number);
}
public static void addToPlaylist(final Context context, final long[] ids, final long playlistid) {
final int size = ids.length;
final ContentResolver resolver = context.getContentResolver();
final String[] projection = new String[] { "max(" + "play_order" + ")" };
final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistid);
Cursor cursor = null;
int base = 0;
try {
cursor = resolver.query(uri, projection, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
base = cursor.getInt(0) + 1;
}
} finally {
if (cursor != null) {
cursor.close();
cursor = null;
}
}
int numinserted = 0;
for (int offSet = 0; offSet < size; offSet += 1000) {
makeInserreplacedems(ids, offSet, 1000, base);
numinserted += resolver.bulkInsert(uri, mContentValuesCache);
}
final String message = context.getResources().getQuanreplacedyString(R.plurals.NNNtrackstoplaylist, numinserted, numinserted);
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
public static void makeInserreplacedems(final long[] ids, final int offset, int len, final int base) {
if (offset + len > ids.length) {
len = ids.length - offset;
}
if (mContentValuesCache == null || mContentValuesCache.length != len) {
mContentValuesCache = new ContentValues[len];
}
for (int i = 0; i < len; i++) {
if (mContentValuesCache[i] == null) {
mContentValuesCache[i] = new ContentValues();
}
mContentValuesCache[i].put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, base + offset + i);
mContentValuesCache[i].put(MediaStore.Audio.Playlists.Members.AUDIO_ID, ids[offset + i]);
}
}
public static final long createPlaylist(final Context context, final String name) {
if (name != null && name.length() > 0) {
final ContentResolver resolver = context.getContentResolver();
final String[] projection = new String[] { MediaStore.Audio.PlaylistsColumns.NAME };
final String selection = MediaStore.Audio.PlaylistsColumns.NAME + " = '" + name + "'";
Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, projection, selection, null, null);
if (cursor.getCount() <= 0) {
final ContentValues values = new ContentValues(1);
values.put(MediaStore.Audio.PlaylistsColumns.NAME, name);
final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, values);
return Long.parseLong(uri.getLastPathSegment());
}
if (cursor != null) {
cursor.close();
cursor = null;
}
return -1;
}
return -1;
}
public static final void openFile(final String path) {
if (mService != null) {
try {
mService.openFile(path);
} catch (final RemoteException ignored) {
}
}
}
public static final clreplaced ServiceBinder implements ServiceConnection {
private final ServiceConnection mCallback;
private final Context mContext;
public ServiceBinder(final ServiceConnection callback, final Context context) {
mCallback = callback;
mContext = context;
}
@Override
public void onServiceConnected(final ComponentName clreplacedName, final IBinder service) {
mService = ITimberService.Stub.asInterface(service);
if (mCallback != null) {
mCallback.onServiceConnected(clreplacedName, service);
}
initPlaybackServiceWithSettings(mContext);
}
@Override
public void onServiceDisconnected(final ComponentName clreplacedName) {
if (mCallback != null) {
mCallback.onServiceDisconnected(clreplacedName);
}
mService = null;
}
}
public static final clreplaced ServiceToken {
public ContextWrapper mWrappedContext;
public ServiceToken(final ContextWrapper context) {
mWrappedContext = context;
}
}
}
19
Source : VenvyDBController.java
with GNU General Public License v3.0
from VideoOS
with GNU General Public License v3.0
from VideoOS
public void insert(String tableName, String[] columns, String[] contents, int startIndex) throws DBException {
try {
if (isNotOpen()) {
return;
}
dbHandler.beginTransaction();
ContentValues contentValues = buildContentValues(columns, startIndex, contents);
long temp = dbHandler.insert(tableName, contentValues);
if (-1 == temp) {
throw new DBException(getClreplaced().getSimpleName() + ": insert error ");
}
dbHandler.commitTransaction();
} finally {
dbHandler.endTransaction();
}
}
19
Source : VenvyDBController.java
with GNU General Public License v3.0
from VideoOS
with GNU General Public License v3.0
from VideoOS
public boolean update(String tableName, int userIdIndex, int otherIdIndex, String[] columns, int startIndex, String[] contents, String otherid, String userid) throws DBException {
if (isNotOpen()) {
return false;
}
ContentValues contentValues = buildContentValues(columns, startIndex, contents);
String whereClause = columns[userIdIndex] + "=? and " + columns[otherIdIndex] + "=?";
String[] whereArgs = { userid, otherid };
int temp = dbHandler.update(tableName, contentValues, whereClause, whereArgs);
return temp >= 1;
}
19
Source : VenvyDBController.java
with GNU General Public License v3.0
from VideoOS
with GNU General Public License v3.0
from VideoOS
public void insert(String tableName, String[] columns, @NonNull List<String[]> contents, int startIndex) throws DBException {
try {
if (isNotOpen()) {
return;
}
dbHandler.beginTransaction();
for (String[] content : contents) {
ContentValues contentValues = buildContentValues(columns, startIndex, content);
long temp = dbHandler.insert(tableName, contentValues);
if (-1 == temp) {
throw new DBException(getClreplaced().getSimpleName() + ": insert error ");
}
}
dbHandler.commitTransaction();
} finally {
dbHandler.endTransaction();
}
}
19
Source : VenvyDBController.java
with GNU General Public License v3.0
from VideoOS
with GNU General Public License v3.0
from VideoOS
public boolean update(String tableName, String[] columns, String[] contents, String targetColumn, String targetColumnValue, int startIndex) throws DBException {
try {
if (isNotOpen()) {
return false;
}
dbHandler.beginTransaction();
ContentValues contentValues = buildContentValues(columns, startIndex, contents);
String whereClause = targetColumn + "=?";
String[] whereArgs = { targetColumnValue };
int temp = dbHandler.update(tableName, contentValues, whereClause, whereArgs);
dbHandler.commitTransaction();
return temp >= 1;
} catch (Exception e) {
VenvyLog.e("DBException: ", e);
} finally {
dbHandler.endTransaction();
}
return false;
}
19
Source : DBHandler.java
with GNU General Public License v3.0
from VideoOS
with GNU General Public License v3.0
from VideoOS
public long insert(String table, ContentValues contentValues) {
long result;
try {
result = db.insert(table, null, contentValues);
} catch (Exception e) {
return -1;
}
return result;
}
19
Source : PhotoUtils.java
with Apache License 2.0
from vanhung1710
with Apache License 2.0
from vanhung1710
public static void addImageToGallery(final String filePath, final Context context) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
values.put(MediaStore.Images.Media.MIME_TYPE, "image/png");
values.put(MediaStore.MediaColumns.DATA, filePath);
context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
}
19
Source : SQLiteDataBase.java
with MIT License
from usernameyangyan
with MIT License
from usernameyangyan
/**
* 更新数据
* -1失败
*/
public <T> boolean update(T model, String whereClause, String[] whereArgs) {
ContentValues contentValues = new ContentValues();
SqlHelper.parseModelToContentValues(model, contentValues);
return db.update(SqlHelper.getBeanName((model).getClreplaced().getName()), contentValues, whereClause, whereArgs) == 1;
}
19
Source : SQLiteDataBase.java
with MIT License
from usernameyangyan
with MIT License
from usernameyangyan
/**
* 插入数据
* -1 代表失败
*/
public <T> boolean insert(T model) {
db.execSQL(SqlHelper.createTable((model).getClreplaced()));
ContentValues contentValues = new ContentValues();
SqlHelper.parseModelToContentValues(model, contentValues);
return db.insertOrReplace(SqlHelper.getBeanName((model).getClreplaced().getName()), contentValues) > -1;
}
19
Source : DbSqlite.java
with MIT License
from usernameyangyan
with MIT License
from usernameyangyan
/**
* insert or replace a record by if its value of primary key has exsits
*
* @param table
* @param values
* @return the row ID of the newly inserted row, or -1 if an error occurred
*/
public long insertOrReplace(String table, ContentValues values) {
try {
openDB();
return mSQLiteDatabase.replaceOrThrow(table, null, values);
} catch (SQLException ex) {
ex.printStackTrace();
throw ex;
}
}
19
Source : Service.java
with GNU General Public License v3.0
from twireapp
with GNU General Public License v3.0
from twireapp
private static void updateStreamerInfoDbWithValues(ContentValues values, Context context, String streamerName) {
updateStreamerInfoDbWithValues(values, context, SubscriptionsDbHelper.COLUMN_STREAMER_NAME + "=?", new String[] { streamerName });
}
19
Source : MessageFragment.java
with GNU General Public License v3.0
from treasure-lau
with GNU General Public License v3.0
from treasure-lau
private void loadMessageContent() {
getLoaderManager().restartLoader(0, getArguments(), this);
String from = getArguments().getString(SipMessage.FIELD_FROM);
if (!TextUtils.isEmpty(from)) {
ContentValues args = new ContentValues();
args.put(SipMessage.FIELD_READ, true);
getActivity().getContentResolver().update(SipMessage.MESSAGE_URI, args, SipMessage.FIELD_FROM + "=?", new String[] { from });
}
}
19
Source : AccountsEditListFragment.java
with GNU General Public License v3.0
from treasure-lau
with GNU General Public License v3.0
from treasure-lau
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && data != null && data.getExtras() != null) {
if (requestCode == CHOOSE_WIZARD) {
// Wizard has been choosen, now create an account
String wizardId = data.getStringExtra(WizardUtils.ID);
if (wizardId != null) {
showDetails(SipProfile.INVALID_ID, wizardId);
}
} else if (requestCode == CHANGE_WIZARD) {
// Change wizard done for this account.
String wizardId = data.getStringExtra(WizardUtils.ID);
long accountId = data.getLongExtra(Intent.EXTRA_UID, SipProfile.INVALID_ID);
if (wizardId != null && accountId != SipProfile.INVALID_ID) {
ContentValues cv = new ContentValues();
cv.put(SipProfile.FIELD_WIZARD, wizardId);
getActivity().getContentResolver().update(ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, accountId), cv, null, null);
}
}
}
}
19
Source : AccountsEditListFragment.java
with GNU General Public License v3.0
from treasure-lau
with GNU General Public License v3.0
from treasure-lau
/*
@Override
public void onQuit() {
curCheckPosition = SipProfile.INVALID_ID;
if(dualPane) {
showDetails(curCheckPosition, null);
}
}
@Override
public void onShowProfile(long profileId) {
curCheckPosition = profileId;
updateCheckedItem();
}
*/
@Override
public void onToggleRow(AccountRowTag tag) {
ContentValues cv = new ContentValues();
cv.put(SipProfile.FIELD_ACTIVE, !tag.activated);
getActivity().getContentResolver().update(ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, tag.accountId), cv, null, null);
}
19
Source : Filter.java
with GNU General Public License v3.0
from treasure-lau
with GNU General Public License v3.0
from treasure-lau
public void createFromContentValue(ContentValues args) {
Integer tmp_i;
String tmp_s;
tmp_i = args.getAsInteger(_ID);
if (tmp_i != null) {
id = tmp_i;
}
tmp_i = args.getAsInteger(FIELD_PRIORITY);
if (tmp_i != null) {
priority = tmp_i;
}
tmp_i = args.getAsInteger(FIELD_ACTION);
if (tmp_i != null) {
action = tmp_i;
}
tmp_s = args.getreplacedtring(FIELD_MATCHES);
if (tmp_s != null) {
matchPattern = tmp_s;
}
tmp_s = args.getreplacedtring(FIELD_REPLACE);
if (tmp_s != null) {
replacePattern = tmp_s;
}
tmp_i = args.getAsInteger(FIELD_ACCOUNT);
if (tmp_i != null) {
account = tmp_i;
}
}
19
Source : SipProfileState.java
with GNU General Public License v3.0
from treasure-lau
with GNU General Public License v3.0
from treasure-lau
/**
* Fill account state object from content values.
* @param args content values to wrap.
*/
public final void createFromContentValue(ContentValues args) {
Integer tmp_i;
String tmp_s;
Boolean tmp_b;
tmp_i = args.getAsInteger(ACCOUNT_ID);
if (tmp_i != null) {
databaseId = tmp_i;
}
tmp_i = args.getAsInteger(PJSUA_ID);
if (tmp_i != null) {
pjsuaId = tmp_i;
}
tmp_s = args.getreplacedtring(WIZARD);
if (tmp_s != null) {
wizard = tmp_s;
}
tmp_b = args.getAsBoolean(ACTIVE);
if (tmp_b != null) {
active = tmp_b;
}
tmp_i = args.getAsInteger(STATUS_CODE);
if (tmp_i != null) {
statusCode = tmp_i;
}
tmp_s = args.getreplacedtring(STATUS_TEXT);
if (tmp_s != null) {
statusText = tmp_s;
}
tmp_i = args.getAsInteger(ADDED_STATUS);
if (tmp_i != null) {
addedStatus = tmp_i;
}
tmp_i = args.getAsInteger(EXPIRES);
if (tmp_i != null) {
expires = tmp_i;
}
tmp_s = args.getreplacedtring(DISPLAY_NAME);
if (tmp_s != null) {
displayName = tmp_s;
}
tmp_s = args.getreplacedtring(REG_URI);
if (tmp_s != null) {
regUri = tmp_s;
}
tmp_i = args.getAsInteger(PRIORITY);
if (tmp_i != null) {
priority = tmp_i;
}
}
19
Source : SipMessage.java
with GNU General Public License v3.0
from treasure-lau
with GNU General Public License v3.0
from treasure-lau
public final void createFromContentValue(ContentValues args) {
Integer tmp_i;
String tmp_s;
Long tmp_l;
Boolean tmp_b;
tmp_s = args.getreplacedtring(FIELD_FROM);
if (tmp_s != null) {
from = tmp_s;
}
tmp_s = args.getreplacedtring(FIELD_TO);
if (tmp_s != null) {
to = tmp_s;
}
tmp_s = args.getreplacedtring(FIELD_CONTACT);
if (tmp_s != null) {
contact = tmp_s;
}
tmp_s = args.getreplacedtring(FIELD_BODY);
if (tmp_s != null) {
body = tmp_s;
}
tmp_s = args.getreplacedtring(FIELD_MIME_TYPE);
if (tmp_s != null) {
mimeType = tmp_s;
}
tmp_l = args.getAsLong(FIELD_DATE);
if (tmp_l != null) {
date = tmp_l;
}
tmp_i = args.getAsInteger(FIELD_TYPE);
if (tmp_i != null) {
type = tmp_i;
}
tmp_i = args.getAsInteger(FIELD_STATUS);
if (tmp_i != null) {
status = tmp_i;
}
tmp_b = args.getAsBoolean(FIELD_READ);
if (tmp_b != null) {
read = tmp_b;
}
tmp_s = args.getreplacedtring(FIELD_FROM_FULL);
if (tmp_s != null) {
fullFrom = tmp_s;
}
}
19
Source : SQLHelper.java
with Apache License 2.0
from TommyLemon
with Apache License 2.0
from TommyLemon
/**
* 插入数据
* @param column - 列名称
* @param value - 筛选数据的条件值
* @param values - 一行键值对数据
*/
public void put(String column, String value, ContentValues values) {
ContentValues oldValues = get(column, value);
if (oldValues != null && oldValues.containsKey(COLUMN_ID) && StringUtil.isNotEmpty(oldValues.get(COLUMN_ID), true)) {
// 数据存在且有效
update(column, value, values);
} else {
insert(values);
}
}
19
Source : SQLHelper.java
with Apache License 2.0
from TommyLemon
with Apache License 2.0
from TommyLemon
/**
* 更新数据
* @param id
* @param values
* @return
*/
public int update(int id, ContentValues values) {
return update(COLUMN_ID, "" + id, values);
}
19
Source : SQLHelper.java
with Apache License 2.0
from TommyLemon
with Apache License 2.0
from TommyLemon
/**
* 插入数据
* @param id
* @param values - 一行键值对数据
* @return
*/
public void put(int id, ContentValues values) {
put(COLUMN_ID, "" + id, values);
}
19
Source : PluginDatabaseManager.java
with Apache License 2.0
from Tamicer
with Apache License 2.0
from Tamicer
/**
* update
*
* @param values values
* @param selectionArgs args
* @return result code
*/
public long update(ContentValues values, String[] selectionArgs) {
return PluginSQLiteHelper.update(getDB(), values, selectionArgs);
}
19
Source : SPContentProvider.java
with Apache License 2.0
from stytooldex
with Apache License 2.0
from stytooldex
// 向空闲列表中插入一条记录。
private void insert(ContentValues v) {
synchronized (mCachedDataIde) {
mCachedDataIde.offer(v);
}
if (isIdle.compareAndSet(true, false)) {
// Log.d(TAG, "insert>>>>>>");
mThreadHold.submit(mInsertThread);
}
}
19
Source : SQLiteCursorLoader.java
with Apache License 2.0
from sevar83
with Apache License 2.0
from sevar83
public void replace(String table, String nullColumnHack, ContentValues values) {
new ReplaceTask(this).execute(db, table, nullColumnHack, values);
}
See More Examples