Java Examples for android.content.ContentValues
The following java examples will help you to understand the usage of android.content.ContentValues. These source code samples are taken from different open source projects.
Example 1
| Project: SayItFromTheSky-master File: ContentValuesHelper.java View source code |
/**
* Convert a {@link fr.tvbarthel.apps.sayitfromthesky.models.Drawing} to {@link android.content.ContentValues}.
*
* @param drawing the {@link fr.tvbarthel.apps.sayitfromthesky.models.Drawing} to be converted.
* @return a new {@link android.content.ContentValues} representing the {@link fr.tvbarthel.apps.sayitfromthesky.models.Drawing}.
*/
public static ContentValues drawingToContentValues(Drawing drawing) {
final ContentValues contentValues = new ContentValues();
contentValues.put(DrawingContract.Columns.COLUMN_TITLE, drawing.getTitle());
contentValues.put(DrawingContract.Columns.COLUMN_CREATION_TIME, drawing.getCreationTimeInMillis());
contentValues.put(DrawingContract.Columns.COLUMN_ENCODED_POLYLINES, GSON.toJson(drawing.getEncodedPolylines().toArray()));
return contentValues;
}Example 2
| Project: android_xcore-master File: TestReflectUtils.java View source code |
public void testContentValueByteConvertation() throws Exception {
ContentValues values = new ContentValues();
values.put("key1", true);
values.put("key2", "value");
byte[] byteArray = BytesUtils.toByteArray(values);
ContentValues createFromParcel = BytesUtils.contentValuesFromByteArray(byteArray);
assertTrue(createFromParcel.getAsBoolean("key1") && true);
assertEquals(createFromParcel.getAsString("key2"), "value");
ContentValues[] contentValues = new ContentValues[2];
contentValues[0] = values;
values = new ContentValues();
values.put("key3", false);
values.put("key4", "val2");
contentValues[1] = values;
byteArray = BytesUtils.arrayToByteArray(contentValues);
contentValues = BytesUtils.arrayContentValuesFromByteArray(byteArray);
assertEquals(contentValues.length, 2);
}Example 3
| Project: all_demo-master File: UpgradeInfo.java View source code |
public ContentValues getContentValues() { final ContentValues values = new ContentValues(); values.put(MarketProvider.COLUMN_P_ID, pid); values.put(MarketProvider.COLUMN_P_NEW_VERSION_NAME, versionName); values.put(MarketProvider.COLUMN_P_NEW_VERSION_CODE, versionCode); values.put(MarketProvider.COLUMN_P_PACKAGE_NAME, pkgName); values.put(MarketProvider.COLUMN_P_IGNORE, update); return values; }
Example 4
| Project: andstatus-master File: MsgOfUserValuesTest.java View source code |
public void testCreationFromContentValues() {
ContentValues contentValues = new ContentValues();
long userId = 0;
long msgId = 2;
MsgOfUserValues userValues = MsgOfUserValues.valueOf(userId, contentValues);
assertFalse(userValues.isValid());
userId = 1;
userValues = MsgOfUserValues.valueOf(userId, contentValues);
assertFalse(userValues.isValid());
userValues.setMsgId(msgId);
assertTrue(userValues.isValid());
assertTrue(userValues.isEmpty());
contentValues.put(MsgOfUserTable.SUBSCRIBED, true);
userValues = MsgOfUserValues.valueOf(userId, contentValues);
assertFalse(userValues.isValid());
userValues.setMsgId(msgId);
assertTrue(userValues.isValid());
assertFalse(userValues.isEmpty());
}Example 5
| Project: audit-master File: MainActivity.java View source code |
private void dataBase() {
try {
String dirPath = Environment.getExternalStorageDirectory().getPath() + "/test/";
SQLiteDatabase db = this.openOrCreateDatabase(dirPath + "contextWrapper", 3, null);
String sql = "CREATE TABLE test (_id INTEGER PRIMARY KEY , filename VARCHAR, data TEXT)";
db.execSQL(sql);
ContentValues cv = new ContentValues();
cv.put("_id", 1);
cv.put("filename", "testfilename");
cv.put("data", " 测试我的数�库");
db.insert("test", null, cv);
} catch (Exception e) {
e.printStackTrace();
}
}Example 6
| Project: email-master File: MigrationTo50.java View source code |
public static void foldersAddNotifyClassColumn(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
try {
db.execSQL("ALTER TABLE folders ADD notify_class TEXT default '" + Folder.FolderClass.INHERITED.name() + "'");
} catch (SQLiteException e) {
if (!e.getMessage().startsWith("duplicate column name:")) {
throw e;
}
}
ContentValues cv = new ContentValues();
cv.put("notify_class", Folder.FolderClass.FIRST_CLASS.name());
Account account = migrationsHelper.getAccount();
db.update("folders", cv, "name = ?", new String[] { account.getInboxFolderName() });
}Example 7
| Project: GlanceTweet-master File: MarkAllReadActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "MarkAllReadActivity");
DatabaseHelper mOpenHelper = new DatabaseHelper(this);
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
ContentValues args = new ContentValues();
args.put("read", 1);
args.put("photo", new byte[] {});
db.update(TABLE_NAME, args, "id>0", null);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.cancel(Constants.NOTIF_SHOW_TWEETS);
finish();
}Example 8
| Project: k-9-master File: MigrationTo50.java View source code |
public static void foldersAddNotifyClassColumn(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
try {
db.execSQL("ALTER TABLE folders ADD notify_class TEXT default '" + Folder.FolderClass.INHERITED.name() + "'");
} catch (SQLiteException e) {
if (!e.getMessage().startsWith("duplicate column name:")) {
throw e;
}
}
ContentValues cv = new ContentValues();
cv.put("notify_class", Folder.FolderClass.FIRST_CLASS.name());
Account account = migrationsHelper.getAccount();
db.update("folders", cv, "name = ?", new String[] { account.getInboxFolderName() });
}Example 9
| Project: SecurityShepherd-master File: MainActivity.java View source code |
public void addKey(View view) {
String key = keyEditText.getText().toString();
ContentValues values = new ContentValues();
values.put(mProvider.key, key);
// Provides access to other applications Content Providers
Uri uri = getContentResolver().insert(mProvider.CONTENT_URL, values);
Toast.makeText(getBaseContext(), "New Secret Added", Toast.LENGTH_LONG).show();
}Example 10
| Project: shoppinglist-master File: AutomationActions.java View source code |
public static void cleanUpList(Context context, Uri uri) {
if (uri != null) {
long id = Integer.parseInt(uri.getLastPathSegment());
// by changing state
ContentValues values = new ContentValues();
values.put(Contains.STATUS, Status.REMOVED_FROM_LIST);
context.getContentResolver().update(Contains.CONTENT_URI, values, ShoppingContract.Contains.LIST_ID + " = " + id + " AND " + ShoppingContract.Contains.STATUS + " = " + ShoppingContract.Status.BOUGHT, null);
}
}Example 11
| Project: sprinkles-master File: StringSerializerTest.java View source code |
@Test
public void serialize() {
StringSerializer serializer = new StringSerializer();
String name = "string";
String obj = "sprinkles";
ContentValues cv = new ContentValues();
serializer.pack(obj, cv, name);
MatrixCursor c = new MatrixCursor(new String[] { name });
c.addRow(new Object[] { cv.getAsString(name) });
c.moveToFirst();
assertTrue(serializer.unpack(c, name).equals("sprinkles"));
}Example 12
| Project: unutopia-android-master File: myBroadcastReceiver.java View source code |
@Override
public void onReceive(Context arg0, Intent intent) {
// TODO Auto-generated method stub
Log.d(TAG, "onReceive");
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state != null && state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
String tlf = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
Log.d(TAG, "Llamada entrante de " + tlf);
ContentValues values = new ContentValues();
values.put(CallsContract.UsersTable.NUMBER, tlf);
Uri uri = CallsContract.UsersTable.getUri();
Uri newUri = mContentResolver.insert(uri, values);
}
}Example 13
| Project: zaduiReader-master File: RssHelper.java View source code |
public static ContentValues feedItemToContentValues(RSSItem item) { ContentValues cv = new ContentValues(); cv.put(Archives._ID, Long.valueOf(item.getGuid())); cv.put(Archives.GUID, item.getGuid()); cv.put(Archives.TITLE, item.getTitle()); cv.put(Archives.DESC, item.getDescription()); cv.put(Archives.LINK, item.getLink().toString()); cv.put(Archives.THUMB_URL, item.getThumbUrl()); cv.put(Archives.PUB_DATE, item.getPubDate().getTime()); Log.d(TAG, item.getGuid() + "|" + item.getTitle() + "|" + item.getDescription()); return cv; }
Example 14
| Project: Kore-master File: SyncUtils.java View source code |
/**
* Returns {@link android.content.ContentValues} from a {@link org.xbmc.kore.jsonrpc.type.VideoType.DetailsMovie} movie
* @param hostId Host id for this movie
* @param movie {@link org.xbmc.kore.jsonrpc.type.VideoType.DetailsMovie}
* @return {@link android.content.ContentValues} with the movie values
*/
public static ContentValues contentValuesFromMovie(int hostId, VideoType.DetailsMovie movie) {
ContentValues movieValues = new ContentValues();
movieValues.put(MediaContract.MoviesColumns.HOST_ID, hostId);
movieValues.put(MediaContract.MoviesColumns.MOVIEID, movie.movieid);
movieValues.put(MediaContract.MoviesColumns.FANART, movie.fanart);
movieValues.put(MediaContract.MoviesColumns.THUMBNAIL, movie.thumbnail);
movieValues.put(MediaContract.MoviesColumns.PLAYCOUNT, movie.playcount);
movieValues.put(MediaContract.MoviesColumns.DATEADDED, movie.dateadded);
movieValues.put(MediaContract.MoviesColumns.LASTPLAYED, movie.lastplayed);
movieValues.put(MediaContract.MoviesColumns.TITLE, movie.title);
movieValues.put(MediaContract.MoviesColumns.FILE, movie.file);
movieValues.put(MediaContract.MoviesColumns.PLOT, movie.plot);
movieValues.put(MediaContract.MoviesColumns.DIRECTOR, Utils.listStringConcat(movie.director, LIST_DELIMITER));
movieValues.put(MediaContract.MoviesColumns.RUNTIME, movie.runtime);
if (movie.streamdetails != null) {
if (movie.streamdetails.audio.size() > 0) {
// Get the stream with the most channels and concat all the languages
VideoType.Streams.Audio selectedStream = movie.streamdetails.audio.get(0);
List<String> languages = new ArrayList<String>(movie.streamdetails.audio.size());
for (int j = 0; j < movie.streamdetails.audio.size(); j++) {
VideoType.Streams.Audio stream = movie.streamdetails.audio.get(0);
if (stream.channels > selectedStream.channels) {
selectedStream = stream;
}
languages.add(stream.language);
}
movieValues.put(MediaContract.MoviesColumns.AUDIO_CHANNELS, selectedStream.channels);
movieValues.put(MediaContract.MoviesColumns.AUDIO_CODEC, selectedStream.codec);
movieValues.put(MediaContract.MoviesColumns.AUDIO_LANGUAGE, Utils.listStringConcat(languages, LIST_DELIMITER));
}
if (movie.streamdetails.subtitle.size() > 0) {
// Concat all subtitle languages
ArrayList<String> subtitles = new ArrayList<String>(movie.streamdetails.subtitle.size());
for (int j = 0; j < movie.streamdetails.subtitle.size(); j++) {
subtitles.add(movie.streamdetails.subtitle.get(j).language);
}
movieValues.put(MediaContract.MoviesColumns.SUBTITLES_LANGUAGES, Utils.listStringConcat(subtitles, LIST_DELIMITER));
}
if (movie.streamdetails.video.size() > 0) {
// We're only getting the first video channel...
movieValues.put(MediaContract.MoviesColumns.VIDEO_ASPECT, movie.streamdetails.video.get(0).aspect);
movieValues.put(MediaContract.MoviesColumns.VIDEO_CODEC, movie.streamdetails.video.get(0).codec);
movieValues.put(MediaContract.MoviesColumns.VIDEO_HEIGHT, movie.streamdetails.video.get(0).height);
movieValues.put(MediaContract.MoviesColumns.VIDEO_WIDTH, movie.streamdetails.video.get(0).width);
}
}
movieValues.put(MediaContract.MoviesColumns.COUNTRIES, Utils.listStringConcat(movie.country, LIST_DELIMITER));
movieValues.put(MediaContract.MoviesColumns.GENRES, Utils.listStringConcat(movie.genre, LIST_DELIMITER));
movieValues.put(MediaContract.MoviesColumns.IMDBNUMBER, movie.imdbnumber);
movieValues.put(MediaContract.MoviesColumns.MPAA, movie.mpaa);
movieValues.put(MediaContract.MoviesColumns.RATING, movie.rating);
movieValues.put(MediaContract.MoviesColumns.SET, movie.set);
movieValues.put(MediaContract.MoviesColumns.SETID, movie.setid);
movieValues.put(MediaContract.MoviesColumns.STUDIOS, Utils.listStringConcat(movie.studio, LIST_DELIMITER));
movieValues.put(MediaContract.MoviesColumns.TAGLINE, movie.tagline);
movieValues.put(MediaContract.MoviesColumns.TOP250, movie.top250);
movieValues.put(MediaContract.MoviesColumns.TRAILER, movie.trailer);
movieValues.put(MediaContract.MoviesColumns.VOTES, movie.votes);
movieValues.put(MediaContract.MoviesColumns.WRITERS, Utils.listStringConcat(movie.writer, LIST_DELIMITER));
movieValues.put(MediaContract.MoviesColumns.YEAR, movie.year);
return movieValues;
}Example 15
| Project: androidito-master File: SuggestParser.java View source code |
protected void parse(String feedData) throws JSONException {
//TODO - really needs to be redone, this can be inserted as part of the session/speaker parsing as far as I can see
contentResolver.delete(SessionsContract.SearchKeywordSuggest.CONTENT_URI, null, null);
// Parse incoming JSON stream
JSONArray words = new JSONArray(feedData);
List<ContentValues> entries = new ArrayList<ContentValues>();
int wordCount = words.length();
for (int i = 0; i < wordCount; i++) {
String word = words.getString(i);
ContentValues values = new ContentValues();
values.put(SessionsContract.SuggestColumns.DISPLAY, word);
contentResolver.insert(SessionsContract.SearchKeywordSuggest.CONTENT_URI, values);
}
}Example 16
| Project: talkback-master File: LabelProviderTest.java View source code |
/**
* Tests {@link com.android.talkback.labeling.LabelProvider#insert(android.net.Uri, android.content.ContentValues)} with empty content
* values.
*/
@SmallTest
public void testInsert_emptyContentValues() throws RemoteException {
final ContentProviderClient client = getContentProviderClient();
final ContentValues contentValues = new ContentValues();
final Uri resultUri;
try {
resultUri = client.insert(LabelProvider.LABELS_CONTENT_URI, contentValues);
} finally {
client.release();
}
assertNull(resultUri);
}Example 17
| Project: 2Degrees-Toolbox-master File: DBLog.java View source code |
public static void insertMessage(Context c, String severity, String tag, String message) {
DBOpenHelper dbHelper = new DBOpenHelper(c);
SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues values = new ContentValues();
Date now = new Date();
values.put("date_time", DateFormatters.ISO8601FORMAT.format(now));
values.put("severity", severity);
values.put("tag", tag);
values.put("message", message);
db.insert("log", null, values);
if ((int) (Math.random() * 200) == 5) {
Cursor results = db.rawQuery("SELECT COUNT(1) FROM log", null);
results.moveToFirst();
int noLines = results.getInt(0);
results.close();
if (noLines > 50) {
String sql = "DELETE FROM log WHERE `id` IN (SELECT `id` FROM log ORDER BY `id` ASC LIMIT " + (noLines - 50) + ")";
Log.d("2DegreesDBLog", "Deleting " + (noLines - 50) + "rows. Sql: " + sql);
db.execSQL(sql);
}
}
db.close();
}Example 18
| Project: actor-platform-master File: SamsungHomeBadger.java View source code |
@Override
protected void executeBadge(int badgeCount) throws ShortcutBadgeException {
Uri mUri = Uri.parse(CONTENT_URI);
ContentResolver contentResolver = mContext.getContentResolver();
Cursor cursor = null;
try {
cursor = contentResolver.query(mUri, CONTENT_PROJECTION, "package=?", new String[] { getContextPackageName() }, null);
if (cursor != null) {
String entryActivityName = getEntryActivityName();
boolean entryActivityExist = false;
while (cursor.moveToNext()) {
int id = cursor.getInt(0);
ContentValues contentValues = getContentValues(badgeCount, false);
contentResolver.update(mUri, contentValues, "_id=?", new String[] { String.valueOf(id) });
if (entryActivityName.equals(cursor.getString(cursor.getColumnIndex("class")))) {
entryActivityExist = true;
}
}
if (!entryActivityExist) {
ContentValues contentValues = getContentValues(badgeCount, true);
contentResolver.insert(mUri, contentValues);
}
}
} finally {
CloseHelper.close(cursor);
}
}Example 19
| Project: AirCastingAndroidClient-master File: ActualNoteTracker.java View source code |
@Override
public Void execute(SQLiteDatabase writableDatabase) {
ContentValues values = new ContentValues();
values.put(NOTE_SESSION_ID, session.getId());
values.put(NOTE_LATITUDE, note.getLatitude());
values.put(NOTE_LONGITUDE, note.getLongitude());
values.put(NOTE_TEXT, note.getText());
values.put(NOTE_DATE, note.getDate().getTime());
values.put(NOTE_PHOTO, note.getPhotoPath());
values.put(NOTE_NUMBER, note.getNumber());
writableDatabase.insertOrThrow(NOTE_TABLE_NAME, null, values);
return null;
}Example 20
| Project: androGister-master File: UserProviderTest.java View source code |
// public void testQuery(){
// ContentProvider provider = getProvider();
// Uri uri = UserProvider.Constants.CONTENT_URI;
// Cursor cursor = provider.query(uri, null, null, null, null);
// assertNotNull(cursor);
// System.out.println("Cursor result size : " + cursor.getCount());
//
// }
public void testInsertUser() throws OperationApplicationException {
// ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
// // Insert One
// ops.add(ContentProviderOperation.newInsert(UserProvider.Constants.CONTENT_URI)
// .withValue(UserColumns.KEY_FIRSTNAME, "Jame")
// .withValue(UserColumns.KEY_LASTNAME, "Bond")
// .withValue(UserColumns.KEY_MATRICULE, "007")
// .build());
// Do Insert
ContentValues values = new ContentValues();
values.put(UserColumns.KEY_FIRSTNAME, "Jame");
values.put(UserColumns.KEY_LASTNAME, "Bond");
values.put(UserColumns.KEY_MATRICULE, "007");
Uri insertUri = contentResolver.insert(UserProvider.Constants.CONTENT_URI, values);
assertNotNull(insertUri);
System.out.println("Result insert Uri " + insertUri);
}Example 21
| Project: android-development-course-master File: MainActivity.java View source code |
private void insert() {
ContentValues values = new ContentValues();
for (int i = 0; i < 3; i++) {
values.clear();
values.put(Book.COLUMN_NAME_BOOK_TITLE, "TITLE" + i);
values.put(Book.COLUMN_NAME_BOOK_PUBLISHER, "PUBLISHER" + i);
values.put(Book.COLUMN_NAME_BOOK_PRICE, "PRICE" + i);
Uri insert = getContentResolver().insert(Book.CONTENT_URI, values);
Log.d(TAG, insert.toString());
}
}Example 22
| Project: Android-Studio-Project-master File: ProviderActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri bookUri = Uri.parse("content://com.example.mr_wrong.androidstudioproject.provider/book");
//getContentResolver().query(bookUri, new String[]{"_id", "name"}, null, null, null);
ContentValues values = new ContentValues();
values.put("_id", 6);
values.put("name", "开�的艺术");
getContentResolver().insert(bookUri, values);
Cursor bookCursor = getContentResolver().query(bookUri, new String[] { "_id", "name" }, null, null, null);
while (bookCursor.moveToNext()) {
LogUtils.e("id:" + bookCursor.getInt(0) + " name:" + bookCursor.getString(1));
}
bookCursor.close();
Uri userUri = Uri.parse("content://com.example.mr_wrong.androidstudioproject.provider/user");
Cursor userCursor = getContentResolver().query(userUri, new String[] { "_id", "name", "sex" }, null, null, null);
while (userCursor.moveToNext()) {
LogUtils.e("id:" + userCursor.getInt(0) + " name:" + userCursor.getString(1) + " sex:" + userCursor.getInt(2));
//LogUtils.e("æ£åœ¨æŸ¥è¯¢");
}
userCursor.close();
}Example 23
| Project: android-vnc-viewer-master File: ConnectionBean.java View source code |
void save(SQLiteDatabase database) {
ContentValues values = Gen_getValues();
values.remove(GEN_FIELD__ID);
if (!getKeepPassword()) {
values.put(GEN_FIELD_PASSWORD, "");
}
if (isNew()) {
set_Id(database.insert(GEN_TABLE_NAME, null, values));
} else {
database.update(GEN_TABLE_NAME, values, GEN_FIELD__ID + " = ?", new String[] { Long.toString(get_Id()) });
}
}Example 24
| Project: androidmooc-clase4-master File: DBAdapter.java View source code |
public ContentValues buildContentValuesFromPlace(Place p) { ContentValues values = new ContentValues(); values.put(DBHelper.KEY_ID, p.getId()); values.put(DBHelper.KEY_DATE, p.getDate()); values.put(DBHelper.KEY_TIME, p.getTime()); values.put(DBHelper.KEY_AUTHOR, p.getAuthor()); values.put(DBHelper.KEY_THUMBNAILURL, p.getThumbnailURL()); return values; }
Example 25
| Project: AndroidSDK-RecipeBook-master File: MySQLiteOpenHelper.java View source code |
// DB�新�作��れ�時�呼�出�れる。
@Override
public void onCreate(SQLiteDatabase db) {
// テーブル作�
db.execSQL("CREATE TABLE IF NOT EXISTS people" + " (_id INTEGER PRIMARY KEY AUTOINCREMENT," + " name TEXT," + " age INTEGER);");
// �期データを投入
ContentValues values = new ContentValues();
values.put("name", "gabu");
values.put("age", "25");
db.insert("people", null, values);
}Example 26
| Project: AndroidTraining-master File: MainActivity.java View source code |
private void insert() {
ContentValues values = new ContentValues();
for (int i = 0; i < 3; i++) {
values.clear();
values.put(Book.COLUMN_NAME_BOOK_TITLE, "TITLE" + i);
values.put(Book.COLUMN_NAME_BOOK_PUBLISHER, "PUBLISHER" + i);
values.put(Book.COLUMN_NAME_BOOK_PRICE, "PRICE" + i);
Uri insert = getContentResolver().insert(Book.CONTENT_URI, values);
Log.d(TAG, insert.toString());
}
}Example 27
| Project: androidVNC-master File: ConnectionBean.java View source code |
void save(SQLiteDatabase database) {
ContentValues values = Gen_getValues();
values.remove(GEN_FIELD__ID);
if (!getKeepPassword()) {
values.put(GEN_FIELD_PASSWORD, "");
}
if (isNew()) {
set_Id(database.insert(GEN_TABLE_NAME, null, values));
} else {
database.update(GEN_TABLE_NAME, values, GEN_FIELD__ID + " = ?", new String[] { Long.toString(get_Id()) });
}
}Example 28
| Project: AppJone-master File: TestCallRecordsContentProvider.java View source code |
public void testInsert() {
ContentValues contentValues = new ContentValues();
contentValues.put(Constants.CALL_RECORD_NAME, "test测试用01");
contentValues.put(Constants.CALL_RECORD_CALL_TIME, System.currentTimeMillis());
Uri uri = Uri.parse(Constants.CALL_RECORD_URI);
Uri resultUri = mContentResolver.insert(uri, contentValues);
//测试是�真的�入数�了
assertNotNull(resultUri);
//æµ‹è¯•å®Œåˆ é™¤æ‰€æœ‰æ•°æ?®
//mContentResolver.delete(uri, Constants.CALL_RECORD_ID + "=" + "0", null);
}Example 29
| Project: AppLock-master File: LockPrivateManager.java View source code |
public void replaceLockPrivate(LockPrivate lockPrivate) {
ContentValues values = new ContentValues();
values.put("isRead", lockPrivate.isRead());
values.put("lookDate", lockPrivate.getLookDate());
values.put("picPath", lockPrivate.getPicPath());
DataSupport.updateAll(LockPrivate.class, values, "packageName = ?", lockPrivate.getPackageName());
}Example 30
| Project: arca-android-master File: UpdateTest.java View source code |
public void testUpdateParcelableCreator() {
final Uri uri = Uri.parse("content://empty");
final ContentValues values = new ContentValues();
final String where = "test = ?";
final String[] whereArgs = { "true" };
final Update request = new Update(uri, values);
request.setWhere(where, whereArgs);
final Parcel parcel = Parcel.obtain();
request.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
final Update parceled = Update.CREATOR.createFromParcel(parcel);
assertEquals(uri, parceled.getUri());
assertEquals(values, parceled.getContentValues());
assertEquals(where, parceled.getWhereClause());
assertTrue(Arrays.deepEquals(whereArgs, parceled.getWhereArgs()));
parcel.recycle();
}Example 31
| Project: astrid-master File: FilterExposer.java View source code |
@SuppressWarnings("nls")
@Override
public void onReceive(Context context, Intent intent) {
FilterListItem[] list = new FilterListItem[2];
list[0] = new FilterListHeader("Sample Filters");
ContentValues completedValues = new ContentValues();
completedValues.put(Task.COMPLETION_DATE.name, Filter.VALUE_NOW);
list[1] = new Filter("Completed by Alpha", "Completed by Alpha", new QueryTemplate().where(Task.COMPLETION_DATE.gt(0)).orderBy(Order.asc(Task.TITLE)), completedValues);
// transmit filter list
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, list);
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
}Example 32
| Project: bluetooth_social-master File: InsertUserHealper.java View source code |
public static void insertData(Context context) {
Uri uri = UserTableMetaData.CONTENT_URI;
for (int i = 0; i < nicks.length; i++) {
ContentValues values = new ContentValues();
values.put(UserTableMetaData.USER_NAME, nicks[i]);
values.put(UserTableMetaData.USER_MOTTO, "ÊÀ½çÊÇÃÀºÃµÄ£¡" + i);
values.put(UserTableMetaData.USER_PERSONKIND, "friend");
uri = context.getContentResolver().insert(UserTableMetaData.CONTENT_URI, values);
System.out.println("uri----->" + uri.toString());
}
Toast.makeText(context, "³É¹¦×¢²á1-Óû§", Toast.LENGTH_LONG).show();
}Example 33
| Project: boardgamegeek4android-master File: ResetPlaysTask.java View source code |
@Override
protected Boolean doInBackground(Void... params) {
boolean success = SyncService.clearPlays(getContext());
if (success) {
ContentValues values = new ContentValues(1);
values.put(Plays.SYNC_HASH_CODE, 0);
int count = getContext().getContentResolver().update(Plays.CONTENT_URI, values, null, null);
Timber.d("Cleared the hashcode from %,d plays.", count);
SyncService.sync(getContext(), SyncService.FLAG_SYNC_PLAYS);
}
return success;
}Example 34
| Project: Cloudesk-master File: MostRecentBean.java View source code |
public android.content.ContentValues Gen_getValues() { android.content.ContentValues values = new android.content.ContentValues(); values.put(GEN_FIELD__ID, Long.toString(this.gen__Id)); values.put(GEN_FIELD_CONNECTION_ID, Long.toString(this.gen_CONNECTION_ID)); values.put(GEN_FIELD_SHOW_SPLASH_VERSION, Long.toString(this.gen_SHOW_SPLASH_VERSION)); values.put(GEN_FIELD_TEXT_INDEX, Long.toString(this.gen_TEXT_INDEX)); return values; }
Example 35
| Project: commcare-master File: InstanceProviderInsertType.java View source code |
static InstanceProviderInsertType getInsertionType(ContentValues values) {
if (values.containsKey(InstanceProviderAPI.SANDBOX_MIGRATION_SUBMISSION)) {
values.remove(InstanceProviderAPI.SANDBOX_MIGRATION_SUBMISSION);
return InstanceProviderInsertType.SANDBOX_MIGRATED;
} else if (values.containsKey(InstanceProviderAPI.UNINDEXED_SUBMISSION)) {
values.remove(InstanceProviderAPI.UNINDEXED_SUBMISSION);
return InstanceProviderInsertType.UNINDEXED_IMPORT;
}
return InstanceProviderInsertType.SESSION_LINKED;
}Example 36
| Project: coursera-android-master File: CustomContactProviderDemo.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContentResolver contentResolver = getContentResolver();
ContentValues values = new ContentValues();
// Insert first record
values.put(DataContract.DATA, "Record1");
Uri firstRecordUri = contentResolver.insert(DataContract.CONTENT_URI, values);
values.clear();
// Insert second record
values.put(DataContract.DATA, "Record2");
contentResolver.insert(DataContract.CONTENT_URI, values);
values.clear();
// Insert third record
values.put(DataContract.DATA, "Record3");
contentResolver.insert(DataContract.CONTENT_URI, values);
// Delete first record
contentResolver.delete(firstRecordUri, null, null);
// Create and set cursor and list adapter
Cursor c = contentResolver.query(DataContract.CONTENT_URI, null, null, null, null);
setListAdapter(new SimpleCursorAdapter(this, R.layout.list_layout, c, DataContract.ALL_COLUMNS, new int[] { R.id.idString, R.id.data }, 0));
}Example 37
| Project: cowbird-master File: ProtocolDBHelper.java View source code |
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int fromVersion, int toVerson) {
switch(fromVersion) {
case 2:
sqLiteDatabase.execSQL(Protocol.UPGRADE_2_3);
case 3:
ContentValues cv = new ContentValues();
cv.put("operator", "CLARO");
sqLiteDatabase.update(Protocol.TABLE_NAME, cv, "operator=?", new String[] { "Claro" });
case 4:
for (int i = 0; i < Protocol.UPGRADE_3_4.length; i++) {
sqLiteDatabase.execSQL(Protocol.UPGRADE_3_4[i]);
}
}
}Example 38
| Project: CrossFitr-master File: WorkoutSessionRow.java View source code |
@Override public ContentValues toContentValues() { ContentValues vals = super.toContentValues(); vals.put(WorkoutSessionModel.COL_WORKOUT, workout_id); vals.put(WorkoutSessionModel.COL_SCORE, score); vals.put(WorkoutSessionModel.COL_SCORE_TYPE, score_type_id); vals.put(WorkoutSessionModel.COL_CMNT, comments); return vals; }
Example 39
| Project: DataDroid-master File: Person.java View source code |
public ContentValues toContentValues() { ContentValues cv = new ContentValues(); cv.put(DbPerson.Columns.FIRST_NAME.getName(), firstName); cv.put(DbPerson.Columns.LAST_NAME.getName(), lastName); cv.put(DbPerson.Columns.EMAIL.getName(), email); cv.put(DbPerson.Columns.CITY.getName(), city); cv.put(DbPerson.Columns.POSTAL_CODE.getName(), postalCode); cv.put(DbPerson.Columns.AGE.getName(), age); cv.put(DbPerson.Columns.IS_WORKING.getName(), isWorking); return cv; }
Example 40
| Project: digitalocean-swimmer-master File: SSHKeyDao.java View source code |
public long create(SSHKey sshKey) {
ContentValues values = new ContentValues();
values.put(SSHKeyTable.ID, sshKey.getId());
values.put(SSHKeyTable.NAME, sshKey.getName());
values.put(SSHKeyTable.PUBLIC_KEY, sshKey.getPublicKey());
values.put(SSHKeyTable.FINGERPRINT, sshKey.getFingerprint());
return db.insertWithOnConflict(getTableHelper().TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
}Example 41
| Project: download-manager-master File: DownloadDeleter.java View source code |
public void deleteFileAndMediaReference(FileDownloadInfo info) {
if (!TextUtils.isEmpty(info.getMediaProviderUri())) {
resolver.delete(Uri.parse(info.getMediaProviderUri()), null, null);
}
if (!TextUtils.isEmpty(info.getFileName())) {
deleteFileIfExists(info.getFileName());
ContentValues blankData = new ContentValues();
blankData.put(DownloadContract.Downloads.COLUMN_DATA, (String) null);
resolver.update(info.getAllDownloadsUri(), blankData, null, null);
}
}Example 42
| Project: droidkit-4.x-master File: ContentValuesCompat.java View source code |
public static void put(@NonNull ContentValues values, @NonNull String key, @Nullable Object value) {
if (value == null) {
values.putNull(key);
} else if (value instanceof String) {
values.put(key, (String) value);
} else if (value instanceof Byte) {
values.put(key, (Byte) value);
} else if (value instanceof Short) {
values.put(key, (Short) value);
} else if (value instanceof Integer) {
values.put(key, (Integer) value);
} else if (value instanceof Long) {
values.put(key, (Long) value);
} else if (value instanceof Float) {
values.put(key, (Float) value);
} else if (value instanceof Double) {
values.put(key, (Double) value);
} else if (value instanceof Boolean) {
values.put(key, ((Boolean) value) ? 1 : 0);
} else if (value instanceof byte[]) {
values.put(key, (byte[]) value);
} else {
throw new IllegalArgumentException("bad value type: " + value.getClass().getName());
}
}Example 43
| Project: holoreader-master File: MarkReadRunnable.java View source code |
public void run() {
ContentResolver contentResolver = mContext.getContentResolver();
ContentValues contentValues = new ContentValues();
String selection = ArticleDAO.READ + " IS NULL";
String[] selectionArgs = null;
Uri uri;
if (mArticleID != -1) {
uri = Uri.withAppendedPath(RSSContentProvider.URI_ARTICLES, String.valueOf(mArticleID));
} else {
uri = RSSContentProvider.URI_ARTICLES;
if (mFeedID != -1) {
selection = selection + " AND " + ArticleDAO.FEEDID + " = ? ";
selectionArgs = new String[] { String.valueOf(mFeedID) };
}
}
contentValues.put(ArticleDAO.READ, SQLiteHelper.fromDate(new Date()));
contentResolver.update(uri, contentValues, selection, selectionArgs);
}Example 44
| Project: KeyboardTerm-master File: FunctionButton.java View source code |
public ContentValues getValues() { ContentValues values = new ContentValues(); values.put(DBUtils.FIELD_FUNCBTNS_NAME, name); values.put(DBUtils.FIELD_FUNCBTNS_KEYS, keys); values.put(DBUtils.FIELD_FUNCBTNS_SORTNUMBER, sortNumber); values.put(DBUtils.FIELD_FUNCBTNS_OPEN_KEYBOARD, openKeyboard ? 1 : 0); return values; }
Example 45
| Project: kuliah_mobile-master File: CustomContactProviderDemo.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContentResolver contentResolver = getContentResolver();
ContentValues values = new ContentValues();
// Insert first record
values.put(DataContract.DATA, "Record1");
Uri firstRecordUri = contentResolver.insert(DataContract.CONTENT_URI, values);
values.clear();
// Insert second record
values.put(DataContract.DATA, "Record2");
contentResolver.insert(DataContract.CONTENT_URI, values);
values.clear();
// Insert third record
values.put(DataContract.DATA, "Record3");
contentResolver.insert(DataContract.CONTENT_URI, values);
// Delete first record
contentResolver.delete(firstRecordUri, null, null);
// Create and set cursor and list adapter
Cursor c = contentResolver.query(DataContract.CONTENT_URI, null, null, null, null);
setListAdapter(new SimpleCursorAdapter(this, R.layout.list_layout, c, DataContract.ALL_COLUMNS, new int[] { R.id.idString, R.id.data }, 0));
}Example 46
| Project: Lampshade-master File: MoodRow.java View source code |
public void starChanged(Context c, boolean isStared) {
if (isStared) {
mPriority = MoodColumns.STARRED_PRIORITY;
} else {
mPriority = MoodColumns.UNSTARRED_PRIORITY;
}
String rowSelect = MoodColumns._ID + "=?";
String[] rowArg = { "" + id };
ContentValues mNewValues = new ContentValues();
mNewValues.put(MoodColumns.COL_MOOD_PRIORITY, mPriority);
c.getContentResolver().update(MoodColumns.MOODS_URI, mNewValues, rowSelect, rowArg);
}Example 47
| Project: Locast-Core-Android-master File: IdenticalTagFinder.java View source code |
@Override
public Uri getIdenticalChild(DBHelper m2m, Uri parentChildDir, SQLiteDatabase db, String childTable, ContentValues values) {
final Cursor c = db.query(childTable, PROJECTION, Tag.COL_NAME + "=?", new String[] { values.getAsString(Tag.COL_NAME) }, null, null, null);
try {
if (c.moveToFirst()) {
return ContentUris.withAppendedId(parentChildDir, c.getLong(c.getColumnIndex(Tag._ID)));
}
} finally {
c.close();
}
return null;
}Example 48
| Project: messaging-master File: OContentResolver.java View source code |
public int insert(OValues values) {
ContentValues vals = values.toContentValues();
if (!vals.containsKey("id"))
vals.put("id", "0");
if (!vals.containsKey("odoo_name"))
vals.put("odoo_name", mModel.getUser().getAndroidName());
Uri uri = mContext.getContentResolver().insert(mModel.uri(), vals);
return Integer.parseInt(uri.getLastPathSegment());
}Example 49
| Project: mickeydb-master File: BulkInsertHelper.java View source code |
public int insert(ContentResolver resolver, Uri contentUri, List<T> items) {
if (items == null || items.size() == 0) {
return 0;
}
ContentValues[] values = new ContentValues[items.size()];
for (int i = 0; i < values.length; i++) {
T item = items.get(i);
values[i] = createValues(item);
}
return resolver.bulkInsert(contentUri, values);
}Example 50
| Project: moneybalance-master File: CurrencyDataSource.java View source code |
@Override protected ContentValues toContentValues(Currency currency) { ContentValues values = new ContentValues(); values.put(DataBaseHelper.COLUMN_CALCULATION_ID, currency.getCalculationId()); values.put(DataBaseHelper.COLUMN_CURRENCY_CODE, currency.getCurrencyCode()); values.put(DataBaseHelper.COLUMN_RATE_THIS, currency.getExchangeRateThis()); values.put(DataBaseHelper.COLUMN_RATE_MAIN, currency.getExchangeRateMain()); return values; }
Example 51
| Project: MusicDNA-master File: MediaCacheUtils.java View source code |
public static void updateMediaCache(String title, String artist, String album, long id, Context ctx) {
ContentResolver musicResolver = ctx.getContentResolver();
Uri musicUri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
ContentValues newValues = new ContentValues();
newValues.put(android.provider.MediaStore.Audio.Media.TITLE, title);
newValues.put(android.provider.MediaStore.Audio.Media.ARTIST, artist);
newValues.put(android.provider.MediaStore.Audio.Media.ALBUM, album);
int res = musicResolver.update(musicUri, newValues, android.provider.MediaStore.Audio.Media._ID + "=?", new String[] { String.valueOf(id) });
if (res > 0) {
// Toast.makeText(this, "Updated MediaStore cache", Toast.LENGTH_SHORT).show();
}
}Example 52
| Project: News-Android-App-master File: TeslaUnreadManager.java View source code |
public static void PublishUnreadCount(Context context) {
try {
//Check if TeslaUnread is installed before doing some expensive database query
ContentValues cv = new ContentValues();
cv.put("tag", "de.luhmer.owncloudnewsreader/de.luhmer.owncloudnewsreader");
cv.put("count", 0);
context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
//If we get here.. TeslaUnread is installed
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context);
int count = Integer.parseInt(dbConn.getUnreadItemsCountForSpecificFolder(SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS));
cv.put("count", count);
context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
} catch (IllegalArgumentException ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}Example 53
| Project: NyARToolkit2.3.3-master File: WeightingWord.java View source code |
public void weightingRotate() {
WeightDB = new WeightDBcreate(WeightingWord.this);
db = WeightDB.getWritableDatabase();
//setContentView(R.layout.sub);
GlobalMarkername gmn = new GlobalMarkername();
PattID = gmn.GetData();
String sql = "SELECT Weight FROM Personal_Profaile";
int Weight = db.rawQuery(sql, null).getInt(0) + 1;
ContentValues values = new ContentValues();
values.put("Weight", Weight);
System.out.println("�語Weight " + Weight);
int ret;
try {
ret = db.update("Personal_Profaile", values, "PattID = ?", null);
} finally {
WeightDB.close();
}
if (ret == -1) {
//Toast.makeText(WeightDB.this, "Update失敗", Toast.LENGTH_SHORT).show();
} else {
//Toast.makeText(this, "Update�功", Toast.LENGTH_SHORT).show();
}
}Example 54
| Project: NyARToolkit_Android-master File: WeightingWord.java View source code |
public void weightingRotate() {
WeightDB = new WeightDBcreate(WeightingWord.this);
db = WeightDB.getWritableDatabase();
//setContentView(R.layout.sub);
GlobalMarkername gmn = new GlobalMarkername();
PattID = gmn.GetData();
String sql = "SELECT Weight FROM Personal_Profaile";
int Weight = db.rawQuery(sql, null).getInt(0) + 1;
ContentValues values = new ContentValues();
values.put("Weight", Weight);
System.out.println("�語Weight " + Weight);
int ret;
try {
ret = db.update("Personal_Profaile", values, "PattID = ?", null);
} finally {
WeightDB.close();
}
if (ret == -1) {
//Toast.makeText(WeightDB.this, "Update失敗", Toast.LENGTH_SHORT).show();
} else {
//Toast.makeText(this, "Update�功", Toast.LENGTH_SHORT).show();
}
}Example 55
| Project: ohmagePhone-master File: MockContentProviderContext.java View source code |
@Override
public ContentResolver getContentResolver() {
if (mResolver == null) {
mResolver = new MockContentResolver();
mResolver.addProvider(DbContract.CONTENT_AUTHORITY, new MockContentProvider(mContext) {
@Override
public int update(Uri uri, ContentValues values, String where, String[] selectionArgs) {
return MockContentProviderContext.this.update(uri, values, where, selectionArgs);
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
return MockContentProviderContext.this.query(uri, projection, selection, selectionArgs, sortOrder);
}
});
}
return mResolver;
}Example 56
| Project: OneSignal-Android-SDK-master File: EverythingMeHomeBadger.java View source code |
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
ContentValues contentValues = new ContentValues();
contentValues.put(COLUMN_PACKAGE_NAME, componentName.getPackageName());
contentValues.put(COLUMN_ACTIVITY_NAME, componentName.getClassName());
contentValues.put(COLUMN_COUNT, badgeCount);
context.getContentResolver().insert(Uri.parse(CONTENT_URI), contentValues);
}Example 57
| Project: orgzly-android-master File: SparseTreeAction.java View source code |
@Override
public int run(SQLiteDatabase db) {
int result = 0;
CycleVisibilityAction.foldAllNotes(db, bookId);
if (values.containsKey(ID)) {
long noteId = values.getAsLong(ID);
String ancestorsIds = DatabaseUtils.ancestorsIds(db, bookId, noteId);
if (ancestorsIds != null) {
ContentValues v;
v = new ContentValues();
v.put(DbNote.Column.IS_FOLDED, 0);
result = db.update(DbNote.TABLE, v, DbNote.Column._ID + " IN (" + ancestorsIds + ")", null);
v = new ContentValues();
v.put(DbNote.Column.FOLDED_UNDER_ID, 0);
db.update(DbNote.TABLE, v, DbNote.Column.FOLDED_UNDER_ID + " IN (" + ancestorsIds + ")", null);
}
}
return result;
}Example 58
| Project: packages_apps_OneStep-master File: ImageInfo.java View source code |
public Uri getContentUri(Context context) {
if (id != 0) {
return Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "" + id);
} else {
File file = new File(filePath);
if (file.isFile()) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATA, filePath);
return context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
}
}
return null;
}Example 59
| Project: POS-master File: LanguageController.java View source code |
/**
* Returns current language.
* @return current language.
*/
public String getLanguage() {
List<Object> contents = database.select("SELECT * FROM " + DatabaseContents.LANGUAGE);
if (contents.isEmpty()) {
ContentValues defualtLang = new ContentValues();
defualtLang.put("language", DEFAULT_LANGUAGE);
database.insert(DatabaseContents.LANGUAGE.toString(), defualtLang);
return DEFAULT_LANGUAGE;
}
ContentValues content = (ContentValues) contents.get(0);
return content.getAsString("language");
}Example 60
| Project: pretty-ordinary-client-master File: DiskDao.java View source code |
/**
* æ·»åŠ die
*/
public synchronized boolean insertDisk(Disk d) {
if (getDisk(d)) {
return false;
} else {
try {
DBHelper.getSqLitedatabase().beginTransaction();
ContentValues con = new ContentValues();
con.put("id", d.getId());
con.put("name", d.getName());
con.put("disk_no", d.getDisk_no());
con.put("album_id", d.getAlbum_id());
if (DBHelper.getSqLitedatabase().insert("db_disk", null, con) > 0) {
DBHelper.getSqLitedatabase().setTransactionSuccessful();
return true;
}
;
} finally {
DBHelper.getSqLitedatabase().endTransaction();
}
}
return false;
}Example 61
| Project: Prevail-master File: CursorQueryResult.java View source code |
@Override public Iterator<ContentValues> iterator() { Function<Entity, ContentValues> function = new Function<Entity, ContentValues>() { @Override public ContentValues apply(Entity input) { return input.getEntityValues(); } }; CursorEntityIterator iterator = new CursorEntityIterator(mCursor) { @Override public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { ContentValues values = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, values); return new Entity(values); } }; return Iterators.transform(iterator, function); }
Example 62
| Project: remote-desktop-clients-master File: MostRecentBean.java View source code |
public android.content.ContentValues Gen_getValues() { android.content.ContentValues values = new android.content.ContentValues(); values.put(GEN_FIELD__ID, Long.toString(this.gen__Id)); values.put(GEN_FIELD_CONNECTION_ID, Long.toString(this.gen_CONNECTION_ID)); values.put(GEN_FIELD_SHOW_SPLASH_VERSION, Long.toString(this.gen_SHOW_SPLASH_VERSION)); values.put(GEN_FIELD_TEXT_INDEX, Long.toString(this.gen_TEXT_INDEX)); return values; }
Example 63
| Project: SeriesGuide-master File: RenameListTask.java View source code |
@Override
protected boolean doDatabaseUpdate(String listId) {
ContentValues values = new ContentValues();
values.put(SeriesGuideContract.Lists.NAME, listName);
int updated = getContext().getContentResolver().update(SeriesGuideContract.Lists.buildListUri(listId), values, null, null);
if (updated == 0) {
return false;
}
// notify lists activity
EventBus.getDefault().post(new ListsActivity.ListsChangedEvent());
return true;
}Example 64
| Project: ShortcutBadger-master File: EverythingMeHomeBadger.java View source code |
@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
ContentValues contentValues = new ContentValues();
contentValues.put(COLUMN_PACKAGE_NAME, componentName.getPackageName());
contentValues.put(COLUMN_ACTIVITY_NAME, componentName.getClassName());
contentValues.put(COLUMN_COUNT, badgeCount);
context.getContentResolver().insert(Uri.parse(CONTENT_URI), contentValues);
}Example 65
| Project: sonet-master File: ClearNotificationsService.java View source code |
@Override
protected void onHandleIntent(Intent intent) {
ContentValues values = new ContentValues();
values.put(Notifications.CLEARED, 1);
if (intent.hasExtra(EXTRA_STATUS_ID)) {
getContentResolver().update(Notifications.getContentUri(getApplicationContext()), values, Notifications._ID + "=?", new String[] { Long.toString(intent.getLongExtra(EXTRA_STATUS_ID, -1)) });
} else {
getContentResolver().update(Notifications.getContentUri(getApplicationContext()), values, null, null);
}
}Example 66
| Project: storio-master File: PrimitivePrivateFieldsStorIOSQLitePutResolver.java View source code |
/**
* {@inheritDoc}
*/
@Override
@NonNull
public ContentValues mapToContentValues(@NonNull PrimitivePrivateFields object) {
ContentValues contentValues = new ContentValues(8);
contentValues.put("field1", object.isField1());
contentValues.put("field2", object.getField2());
contentValues.put("field3", object.getField3());
contentValues.put("field4", object.getField4());
contentValues.put("field5", object.getField5());
contentValues.put("field6", object.getField6());
contentValues.put("field7", object.getField7());
contentValues.put("field8", object.getField8());
return contentValues;
}Example 67
| Project: stxnext-intranet-android-master File: AbstractDAO.java View source code |
protected void insertOrReplace(String table, ContentValues cv) {
StringBuilder keysBuilder = new StringBuilder();
StringBuilder valuesBuilder = new StringBuilder();
List<Object> values = new ArrayList<Object>();
for (Entry<String, Object> entry : cv.valueSet()) {
if (keysBuilder.length() > 0) {
keysBuilder.append(",");
}
keysBuilder.append(entry.getKey());
if (valuesBuilder.length() > 0) {
valuesBuilder.append(",");
}
valuesBuilder.append("?");
values.add(entry.getValue());
}
StringBuilder sql = new StringBuilder("insert or replace into ").append(table).append(" (");
sql.append(keysBuilder);
sql.append(") values (");
sql.append(valuesBuilder);
sql.append(");");
db.execSQL(sql.toString(), values.toArray());
}Example 68
| Project: trinity-master File: TrinityProcessorTest.java View source code |
@Test
public void fullFiles() {
android.content.ContentValues a;
assert_().about(javaSources()).that(asList(forResource("trinityprocessortest/full/MyEntity.java"), forResource("trinityprocessortest/full/MyRepository.java"), forResource("trinityprocessortest/full/MyObject.java"), forResource("trinityprocessortest/full/MyObjectTypeSerializer.java"))).processedWith(new TrinityProcessor()).compilesWithoutError().and().generatesSources(forResource("trinityprocessortest/full/TrinityMyRepository.java"));
}Example 69
| Project: TruckMuncher-Android-master File: VendorHomeServiceHelper.java View source code |
void changeServingState(Context context, String truckId, boolean isServing, Location location) {
ContentValues values = new ContentValues();
values.put(PublicContract.Truck.LATITUDE, location.getLatitude());
values.put(PublicContract.Truck.LONGITUDE, location.getLongitude());
values.put(PublicContract.Truck.IS_SERVING, isServing);
values.put(Contract.TruckState.IS_DIRTY, true);
Uri uri = Contract.syncToNetwork(Contract.TRUCK_STATE_URI);
WhereClause whereClause = new WhereClause.Builder().where(PublicContract.Truck.ID, EQUALS, truckId).build();
AsyncQueryHandler queryHandler = new SimpleAsyncQueryHandler(context.getContentResolver());
queryHandler.startUpdate(0, null, uri, values, whereClause.selection, whereClause.selectionArgs);
}Example 70
| Project: tuchong-daily-android-master File: AbstractModel.java View source code |
public void save(Context context) {
modelValues = new ContentValues();
nestedModels = new ArrayList<AbstractModel>() {
};
saveToTable(modelValues);
saveNestedModels(nestedModels);
if (TextUtils.isEmpty(tableName)) {
throw new RuntimeException("A Table name must be assigned to the model before saving");
}
SQLiteDatabase db = DBHelper.instance(context).getWritableDatabase();
if (modelValues != null) {
db.insert(tableName, null, modelValues);
}
if (nestedModels != null && nestedModels.size() > 0) {
for (AbstractModel model : nestedModels) {
model.save(context);
}
}
}Example 71
| Project: vnc-master File: MostRecentBean.java View source code |
public android.content.ContentValues Gen_getValues() { android.content.ContentValues values = new android.content.ContentValues(); values.put(GEN_FIELD__ID, Long.toString(this.gen__Id)); values.put(GEN_FIELD_CONNECTION_ID, Long.toString(this.gen_CONNECTION_ID)); values.put(GEN_FIELD_SHOW_SPLASH_VERSION, Long.toString(this.gen_SHOW_SPLASH_VERSION)); values.put(GEN_FIELD_TEXT_INDEX, Long.toString(this.gen_TEXT_INDEX)); return values; }
Example 72
| Project: wosaosao-master File: StaffController.java View source code |
public boolean addStaff(Staff e) {
ContentValues v = new ContentValues();
if (e == null || "".equals(e.getStaffId()) || "".equals(e.getStaffDepartment()) || "".equals(e.getStaffEmail()) || "".equals(e.getStaffName())) {
return false;
}
v.put("staff_id", e.getStaffId());
v.put("name", e.getStaffName());
v.put("staff_department", e.getStaffDepartment());
v.put("staff_email", e.getStaffEmail());
Uri uri = resolver.insert(BookUtil.STAFF_URI, v);
if (uri != null) {
return true;
}
return false;
}Example 73
| Project: zhong-master File: Const.java View source code |
public static final boolean moveItem(ContentResolver res, long playlistId, int from, int to) {
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId).buildUpon().appendEncodedPath(String.valueOf(from)).appendQueryParameter("move", "true").build();
ContentValues values = new ContentValues();
values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, to);
return res.update(uri, values, null, null) != 0;
}Example 74
| Project: androidrocks-master File: IRAProvider.java View source code |
/* (non-Javadoc) * @see android.content.ContentProvider#insert(android.net.Uri, android.content.ContentValues) */ @Override public Uri insert(Uri uri, ContentValues initialValues) { // TODO Auto-generated method stub ContentValues values = new ContentValues(initialValues); SQLiteDatabase db = databaseHelper.getWritableDatabase(); long rowId; switch(uriMatcher.match(uri)) { case DETAILS: rowId = db.insert(IncidentReport.Details.TABLE_NAME, IncidentReport.Details.ID, values); if (rowId > 0) { Uri noteUri = ContentUris.withAppendedId(IncidentReport.Details.CONTENT_URI, rowId); getContext().getContentResolver().notifyChange(noteUri, null); return noteUri; } break; default: throw new IllegalArgumentException("Unknown URI " + uri); } throw new SQLException("Failed to insert row into " + uri); }
Example 75
| Project: openerp-mobile-master File: OEContentProvider.java View source code |
/* * (non-Javadoc) * * @see android.content.ContentProvider#insert(android.net.Uri, * android.content.ContentValues) */ @Override public Uri insert(Uri uri, ContentValues initialValues) { // TODO Auto-generated method stub long rowID = db.getWritableDatabase().insert(TABLE, Constants.TITLE, initialValues); if (rowID > 0) { Uri uriObj = ContentUris.withAppendedId(NoteProvider.Constants.CONTENT_URI, rowID); getContext().getContentResolver().notifyChange(uri, null); return (uriObj); } throw new SQLException("Failed to insert row into " + uri); }
Example 76
| Project: sana.mobile-master File: EventsHelper.java View source code |
/* (non-Javadoc) * @see org.sana.android.db.InsertHelper#onInsert(android.net.Uri, android.content.ContentValues) */ @Override public ContentValues onInsert(ContentValues values) { ContentValues vals = new ContentValues(); vals.put(Contract.UUID, UUID.randomUUID().toString()); vals.put(Contract.EVENT_TYPE, ""); vals.put(Contract.EVENT_VALUE, ""); vals.put(Contract.UPLOADED, false); vals.put(Contract.SUBJECT, ""); vals.put(Contract.ENCOUNTER, ""); vals.put(Contract.OBSERVER, ""); vals.putAll(values); return super.onInsert(vals); }
Example 77
| Project: zprojects-master File: VideoContentProvider.java View source code |
/* * æ·»åŠ æ•°æ?® * @see android.content.ContentProvider#insert(android.net.Uri, android.content.ContentValues) */ @Override public Uri insert(Uri uri, ContentValues values) { // TODO Auto-generated method stub try { if (matcher.match(uri) == INSERT) { Log.i("fenghaitao", "insert"); SQLiteDatabase db = myHelper.getWritableDatabase(); db.insert(DBInfo.Table.TABLE_MEDIA_NAME, null, values); db.close(); } else { throw new IllegalArgumentException("path error,do not insert data"); } } catch (Exception e) { e.printStackTrace(); } return null; }
Example 78
| Project: aero-conf-master File: UpdateOp.java View source code |
@Override
public Integer exec(SQLStore store, Uri uri, ContentValues[] values, String selection, String[] selectionArgs) {
if (selectionArgs == null || selectionArgs[0] == null) {
store.reset();
} else {
Long id = Long.getLong(selectionArgs[0]);
store.remove(id);
}
T object = GsonUtils.GSON.fromJson(values[0].getAsString(ConfContract.DATA), klass);
store.save(object);
if (values[0].getAsBoolean(ConfContract.NOTIFY) != null && values[0].getAsBoolean(ConfContract.NOTIFY)) {
resolver.notifyChange(notifyUri, null, false);
}
return 1;
}Example 79
| Project: akvo-flow-mobile-master File: SurveyLanguageMigratingDbDataSource.java View source code |
public void insertLanguagePreferences(SQLiteDatabase database, long surveyGroupId, @NonNull Set<String> languageCodes) {
ContentValues contentValues = new ContentValues(2);
database.delete(LanguageTable.TABLE_NAME, LanguageTable.COLUMN_SURVEY_ID + " = ?", new String[] { surveyGroupId + "" });
for (String languageCode : languageCodes) {
contentValues.put(LanguageTable.COLUMN_SURVEY_ID, surveyGroupId);
contentValues.put(LanguageTable.COLUMN_LANGUAGE_CODE, languageCode);
database.insert(LanguageTable.TABLE_NAME, null, contentValues);
}
}Example 80
| Project: allogy-legacy-android-app-master File: ListDb.java View source code |
public void addNewList(ContentResolver cr, ListMessage list_msg) {
ContentValues cv = new ContentValues();
boolean yn = isItemInDB(cr, list_msg.getId());
cv.put(List._ID, list_msg.getId());
cv.put(List.TITLE, list_msg.getTitle());
cv.put(List.TAG, list_msg.getTag());
if (!yn)
cr.insert(List.CONTENT_URI, cv);
else
cr.update(List.CONTENT_URI, cv, List._ID + "='" + list_msg.getId() + "'", null);
}Example 81
| Project: android-db-commons-master File: ConvertToContentProviderOperationTest.java View source code |
@Test
public void shouldConstructInsertOperation() throws Exception {
ContentValues values = new ContentValues();
values.put("key", "value");
values.put("second", 2L);
final ContentProviderOperation operation = ProviderAction.insert(createFakeUri("endpoint")).values(values).toContentProviderOperation(Utils.DUMMY_URI_DECORATOR);
final ShadowContentProviderOperation shadowOperation = Robolectric.shadowOf(operation);
assertThat(operation.getUri()).isEqualTo(createFakeUri("endpoint"));
assertThat(shadowOperation.getType()).isEqualTo(ShadowContentProviderOperation.TYPE_INSERT);
assertThat(shadowOperation.getContentValues()).isEqualTo(values);
}Example 82
| Project: Android-Download-Manager-Pro-master File: Chunk.java View source code |
public ContentValues converterToContentValues() { ContentValues contentValues = new ContentValues(); if (id != 0) contentValues.put(CHUNKS.COLUMN_ID, id); contentValues.put(CHUNKS.COLUMN_TASK_ID, task_id); contentValues.put(CHUNKS.COLUMN_BEGIN, begin); contentValues.put(CHUNKS.COLUMN_END, end); contentValues.put(CHUNKS.COLUMN_COMPLETED, completed); return contentValues; }
Example 83
| Project: Android-Media-Library-master File: MediaFactory.java View source code |
public static Media getMediaByUPC(Context mContext, String UPC) throws LookupException {
Media mMedia = null;
ContentResolver cr = mContext.getContentResolver();
// Try to lookup the content with the CR first
Uri myItem = ContentUris.withAppendedId(Media.CONTENT_URI, Long.valueOf(UPC));
Cursor cur = cr.query(myItem, null, null, null, null);
if (cur.getCount() > 0) {
cur.moveToFirst();
mMedia = new Media(cur, cr);
}
cur.close();
if (mMedia != null)
return mMedia;
// Look it up online, then insert it into the CR if we successfully find it
Log.w(TAG, "ContentResolver Miss for UPC: " + UPC);
Log.i(TAG, "Looking up UPC Online...");
String Title = UPCDataSource.getUPCText(UPC).trim();
Log.i(TAG, "UPC Lookup Result: " + Title);
if (Title == "")
throw new LookupException("Could not find Title Anywhere!");
ContentValues mVals = new ContentValues();
mVals.put(Media.TITLE, Title);
mVals.put(Media.BARCODE, UPC);
mVals.put(Media.OWNED, 0);
mVals.put(Media.LOANED, "");
cr.insert(Media.CONTENT_URI, mVals);
// Ok, Mobile platforms probably don't like recursion, but this really is the most graceful way to handle things...
return MediaFactory.getMediaByUPC(mContext, UPC);
}Example 84
| Project: android-messengerpp-master File: ReplacePropertyExec.java View source code |
@Override
public long exec(@Nonnull SQLiteDatabase db) {
final Entity entity = getNotNullObject();
if (propertyValue != null) {
final ContentValues values = new ContentValues();
values.put(idColumnName, entity.getEntityId());
values.put("property_name", propertyName);
values.put("property_value", propertyValue);
return db.replace(tableName, null, values);
} else {
return db.delete(tableName, idColumnName + " = ? and property_name = ? ", new String[] { entity.getEntityId(), propertyName });
}
}Example 85
| Project: android-mms-mod-master File: DrmUtils.java View source code |
public static Uri insert(Context context, DrmWrapper drmObj) throws IOException {
ContentResolver cr = context.getContentResolver();
Uri uri = SqliteWrapper.insert(context, cr, DRM_TEMP_URI, new ContentValues(0));
OutputStream os = null;
try {
os = cr.openOutputStream(uri);
byte[] data = drmObj.getDecryptedData();
if (data != null) {
os.write(data);
}
return uri;
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}
}
}
}Example 86
| Project: android-open-street-map-master File: MapTileEntity.java View source code |
public static void insertTilesForEntity(List<Tile> tiles, int entityId) {
OsmDatabaseHelper db = mDbHelper;
List<ContentValues> values = new ArrayList<ContentValues>();
db.mDb.beginTransaction();
try {
for (Tile tile : tiles) {
String tileId = MapTile.getTileId(tile);
if (tileId != null) {
ContentValues contentValue = new ContentValues();
contentValue.put("tilekey", tileId);
contentValue.put("entityId", entityId);
values.add(contentValue);
}
}
for (ContentValues value : values) {
db.insert(TABLE_TILE_ENTITY_NAME, value);
}
db.mDb.setTransactionSuccessful();
} finally {
db.mDb.endTransaction();
}
}Example 87
| Project: android-sdk-sources-for-api-level-23-master File: VCardBuilderTest.java View source code |
public void testVCardNameFieldFromDisplayName() {
final ArrayList<ContentValues> contentList = Lists.newArrayList();
final ContentValues values = new ContentValues();
values.put(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, "ने");
contentList.add(values);
final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_DEFAULT);
builder.appendNameProperties(contentList);
final String actual = builder.toString();
final String expectedCommon = ";CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:" + "=E0=A4=A8=E0=A5=87";
final String expectedName = "N" + expectedCommon + ";;;;";
final String expectedFullName = "FN" + expectedCommon;
assertTrue("Actual value:\n" + actual + " expected to contain\n" + expectedName + "\nbut does not.", actual.contains(expectedName));
assertTrue("Actual value:\n" + actual + " expected to contain\n" + expectedFullName + "\nbut does not.", actual.contains(expectedFullName));
}Example 88
| Project: android-smsmms-master File: MmsSentReceiver.java View source code |
@Override
public void onReceive(Context context, Intent intent) {
Log.v(TAG, "MMS has finished sending, marking it as so in the database");
Uri uri = Uri.parse(intent.getStringExtra(EXTRA_CONTENT_URI));
Log.v(TAG, uri.toString());
ContentValues values = new ContentValues(1);
values.put(Telephony.Mms.MESSAGE_BOX, Telephony.Mms.MESSAGE_BOX_SENT);
SqliteWrapper.update(context, context.getContentResolver(), uri, values, null, null);
String filePath = intent.getStringExtra(EXTRA_FILE_PATH);
Log.v(TAG, filePath);
new File(filePath).delete();
}Example 89
| Project: AndroidAppYuJing-master File: TopicResponseParam.java View source code |
public List<ContentValues> getAllTopic() { List<ContentValues> list = new LinkedList<ContentValues>(); ContentValues values = null; for (int i = 0; i < array.length(); i++) { values = new ContentValues(); try { JSONObject object = array.getJSONObject(i); values.put(Topic.ID, object.getLong("topicID")); values.put(Topic.UID, object.getLong("topicUID")); values.put(Topic.name, object.getString("topicName")); values.put(Topic.content, object.getString("topicContent")); values.put(Topic.time, object.getInt("topicTime")); values.put(Topic.photo, object.getString("topicPhoto")); list.add(values); } catch (JSONException e) { System.out.println("获得�信内容出错:===" + e.toString()); e.printStackTrace(); } } return list; }
Example 90
| Project: AndroidJUnit4-master File: IsolatedAndroidTestCaseTest.java View source code |
private void invokeDatabaseOperation() {
Context context = getMockContext();
String database = "test.db";
CursorFactory factory = null;
int version = 1;
SQLiteOpenHelper helper = new SQLiteOpenHelper(context, database, factory, version) {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onCreate(db);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table test (_id integer primary key autoincrement not null, name varchar);");
}
};
SQLiteDatabase db = helper.getWritableDatabase();
assertThat(db.query("test", null, null, null, null, null, null).getCount(), is(0));
ContentValues values = new ContentValues();
values.put("name", "foo");
db.insert("test", null, values);
assertThat(db.query("test", null, null, null, null, null, null).getCount(), is(1));
}Example 91
| Project: androidtv-Leanback-master File: FetchVideoService.java View source code |
@Override
protected void onHandleIntent(Intent workIntent) {
VideoDbBuilder builder = new VideoDbBuilder(getApplicationContext());
try {
List<ContentValues> contentValuesList = builder.fetch(getResources().getString(R.string.catalog_url));
ContentValues[] downloadedVideoContentValues = contentValuesList.toArray(new ContentValues[contentValuesList.size()]);
getApplicationContext().getContentResolver().bulkInsert(VideoContract.VideoEntry.CONTENT_URI, downloadedVideoContentValues);
} catch (IOExceptionJSONException | e) {
Log.e(TAG, "Error occurred in downloading videos");
e.printStackTrace();
}
}Example 92
| Project: Android_App_OpenSource-master File: TrackDatabaseBuilder.java View source code |
@Override public ContentValues deconstruct(Track track) { ContentValues values = new ContentValues(); values.put("track_name", track.getName()); values.put("track_stream", track.getStream()); values.put("track_url", track.getUrl()); values.put("track_duration", track.getDuration()); values.put("track_id", track.getId()); values.put("track_rating", track.getRating()); return values; }
Example 93
| Project: android_device_softwinner_cubieboard1-master File: LiveFolderInfo.java View source code |
@Override
void onAddToDatabase(ContentValues values) {
super.onAddToDatabase(values);
values.put(LauncherSettings.Favorites.TITLE, title.toString());
values.put(LauncherSettings.Favorites.URI, uri.toString());
if (baseIntent != null) {
values.put(LauncherSettings.Favorites.INTENT, baseIntent.toUri(0));
}
values.put(LauncherSettings.Favorites.ICON_TYPE, LauncherSettings.Favorites.ICON_TYPE_RESOURCE);
values.put(LauncherSettings.Favorites.DISPLAY_MODE, displayMode);
if (iconResource != null) {
values.put(LauncherSettings.Favorites.ICON_PACKAGE, iconResource.packageName);
values.put(LauncherSettings.Favorites.ICON_RESOURCE, iconResource.resourceName);
}
}Example 94
| Project: android_explore-master File: Activity01.java View source code |
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/* ²åÈëÊý¾Ý */
ContentValues values = new ContentValues();
values.put(NotePad.Notes.TITLE, "title1");
values.put(NotePad.Notes.NOTE, "NOTENOTE1");
getContentResolver().insert(NotePad.Notes.CONTENT_URI, values);
values.clear();
values.put(NotePad.Notes.TITLE, "title2");
values.put(NotePad.Notes.NOTE, "NOTENOTE2");
getContentResolver().insert(NotePad.Notes.CONTENT_URI, values);
/* ÏÔʾ */
displayNote();
}Example 95
| Project: android_packages_apps-master File: ClearMissedCallsService.java View source code |
@Override
protected void onHandleIntent(Intent intent) {
if (ACTION_CLEAR_MISSED_CALLS.equals(intent.getAction())) {
// Clear the list of new missed calls.
ContentValues values = new ContentValues();
values.put(Calls.NEW, 0);
StringBuilder where = new StringBuilder();
where.append(Calls.NEW);
where.append(" = 1 AND ");
where.append(Calls.TYPE);
where.append(" = ?");
getContentResolver().update(Calls.CONTENT_URI, values, where.toString(), new String[] { Integer.toString(Calls.MISSED_TYPE) });
mApp.notificationMgr.cancelMissedCallNotification();
}
}Example 96
| Project: android_packages_apps_Launcher-master File: LiveFolderInfo.java View source code |
@Override
void onAddToDatabase(ContentValues values) {
super.onAddToDatabase(values);
values.put(LauncherSettings.Favorites.TITLE, title.toString());
values.put(LauncherSettings.Favorites.URI, uri.toString());
if (baseIntent != null) {
values.put(LauncherSettings.Favorites.INTENT, baseIntent.toUri(0));
}
values.put(LauncherSettings.Favorites.ICON_TYPE, LauncherSettings.Favorites.ICON_TYPE_RESOURCE);
values.put(LauncherSettings.Favorites.DISPLAY_MODE, displayMode);
if (iconResource != null) {
values.put(LauncherSettings.Favorites.ICON_PACKAGE, iconResource.packageName);
values.put(LauncherSettings.Favorites.ICON_RESOURCE, iconResource.resourceName);
}
}Example 97
| Project: android_programlama_kitap-master File: Main.java View source code |
@Override
public void onClick(View v) {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
try {
ContentValues values = new ContentValues();
values.put("isim", isimText.getText().toString());
values.put("yas", yasText.getText().toString());
db.insert(DatabaseHelper.TABLE_NAME, null, values);
Log.v("DBTEST", "KAYIT EKLENDİ");
} catch (Exception e) {
Log.e("DBTEST", e.toString());
} finally {
db.close();
}
}Example 98
| Project: AppAssit-master File: SunDataHelper.java View source code |
public void bulkInsert(List<SunModel> models) {
ArrayList<ContentValues> contentValueses = new ArrayList<ContentValues>();
for (SunModel model : models) {
ContentValues values = getContentValues(model);
contentValueses.add(values);
}
ContentValues[] valueArray = new ContentValues[contentValueses.size()];
bulkInsert(contentValueses.toArray(valueArray));
}Example 99
| Project: AppDataReader-master File: DataReaderSqliteOpenHelper.java View source code |
public long insert(PersonInfo personInfo) {
// Gets the data repository in write mode
SQLiteDatabase db = getWritableDatabase();
if (db == null || personInfo == null) {
return Constants.INVALID_INSERT_RESPONSE;
}
// Create a new map of values, where column names are the keys
ContentValues values = new ContentValues();
values.put(COLUMN_FIRST_NAME, personInfo.getFirstName());
values.put(COLUMN_LAST_NAME, personInfo.getLastName());
values.put(COLUMN_ADDRESS, personInfo.getAddress());
return db.insert(TABLE_NAME, null, values);
}Example 100
| Project: ASecure-master File: BlacklistsData.java View source code |
public static void migrateOldDataIfPresent(Context context) {
ObjectInputStream ois = null;
HashSet<PhoneNumber> data = null;
try {
ois = new ObjectInputStream(context.openFileInput(BLFILE));
Object o = ois.readObject();
if (o != null && o instanceof Integer) {
// check the version
Integer version = (Integer) o;
if (version == BLFILE_VER) {
Object numbers = ois.readObject();
if (numbers instanceof HashSet) {
data = (HashSet<PhoneNumber>) numbers;
}
}
}
} catch (IOException e) {
} catch (ClassNotFoundException e) {
} finally {
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
}
context.deleteFile(BLFILE);
}
}
if (data != null) {
ContentResolver cr = context.getContentResolver();
ContentValues cv = new ContentValues();
cv.put(Telephony.Blacklist.PHONE_MODE, 1);
for (PhoneNumber number : data) {
Uri uri = Uri.withAppendedPath(Telephony.Blacklist.CONTENT_FILTER_BYNUMBER_URI, number.phone);
cv.put(Telephony.Blacklist.NUMBER, number.phone);
cr.update(uri, cv, null, null);
}
}
}Example 101
| Project: AudioPlayer-master File: DataBaseService.java View source code |
/**
* 查询图片下载历�记录,确定是�下载
*/
public static boolean PICIsNotNull(String artist) {
Cursor cursor = db.rawQuery("SELECT pic_flag FROM his WHERE artist=?", new String[] { artist });
int picflag = PIC_UNSET;
if (cursor.moveToFirst()) {
picflag = cursor.getInt(0);
} else {
ContentValues cv = new ContentValues();
cv.put("artist", artist);
cv.put("pic_flag", PIC_UNSET);
db.insert("his", null, cv);
}
cursor.close();
return picflag == PIC_UNSET;
}