當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentValues.getAsString方法代碼示例

本文整理匯總了Java中android.content.ContentValues.getAsString方法的典型用法代碼示例。如果您正苦於以下問題:Java ContentValues.getAsString方法的具體用法?Java ContentValues.getAsString怎麽用?Java ContentValues.getAsString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.ContentValues的用法示例。


在下文中一共展示了ContentValues.getAsString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: install

import android.content.ContentValues; //導入方法依賴的package包/類
private int install(ContentValues cv) {
    if (cv == null) {
        return 0;
    }

    String pit = cv.getAsString(KEY_PLUGIN_INFO);
    if (TextUtils.isEmpty(pit)) {
        return 0;
    }
    PluginInfo pi = PluginInfo.parseFromJsonText(pit);

    // 開始加載ClassLoader
    ClassLoader cl = PluginMgrFacade.getLocal().loadPluginClassLoader(pi);
    if (cl != null) {
        return 1;
    } else {
        return 0;
    }
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:20,代碼來源:PluginFastInstallProvider.java

示例2: checkFileUriDestination

import android.content.ContentValues; //導入方法依賴的package包/類
/**
 * Check that the file URI provided for DESTINATION_FILE_URI is valid.
 */
private void checkFileUriDestination(ContentValues values) {
    String fileUri = values.getAsString(Downloads.Impl.COLUMN_FILE_NAME_HINT);
    if (fileUri == null) {
        throw new IllegalArgumentException(
                "DESTINATION_FILE_URI must include a file URI under COLUMN_FILE_NAME_HINT");
    }
    Uri uri = Uri.parse(fileUri);
    String scheme = uri.getScheme();
    if (scheme == null || !scheme.equals("file")) {
        throw new IllegalArgumentException("Not a file URI: " + uri);
    }
    final String path = uri.getPath();
    if (path == null) {
        throw new IllegalArgumentException("Invalid file URI: " + uri);
    }

    final File file = new File(path);
   /* if (!PermissionChecker.writeExternalStoragePermission(getContext())) {
        throw new SecurityException("Unsupported path " + file);
    }*/
}
 
開發者ID:redleaf2002,項目名稱:downloadmanager,代碼行數:25,代碼來源:DownloadProvider.java

示例3: insertBus

import android.content.ContentValues; //導入方法依賴的package包/類
private Uri insertBus(Uri uri, ContentValues values) {
    // Check that the name is not null.
    String number = values.getAsString(BusContract.BusEntry.COLUMN_BUS_STOP_NUMBER);
    if (number == null) {
        throw new IllegalArgumentException("Bus requires a number");
    }

    SQLiteDatabase database = mDbHelper.getWritableDatabase();

    // Insert the new bus with the give values.
    long id = database.insert(BusContract.BusEntry.TABLE_NAME, null, values);
    // If the ID is -1, then the insertion failed. Log an error and return null.
    if (id == -1) {
        Log.e(LOG_TAG, "Failed to insert row for " + uri);
        return null;
    }

    // Notify all listeners that the data has changed for the bus content URI.
    getContext().getContentResolver().notifyChange(uri, null);

    // Return the new URI with the ID (of the newly inserted row) appended at the end.
    return ContentUris.withAppendedId(uri, id);
}
 
開發者ID:joshvocal,項目名稱:TransLinkMe-App,代碼行數:24,代碼來源:BusProvider.java

示例4: insertCurrentRook

import android.content.ContentValues; //導入方法依賴的package包/類
private Uri insertCurrentRook(SQLiteDatabase db, Uri uri, ContentValues contentValues) {
    String repoUrl = contentValues.getAsString(ProviderContract.CurrentRooks.Param.REPO_URL);
    String rookUrl = contentValues.getAsString(ProviderContract.CurrentRooks.Param.ROOK_URL);
    String revision = contentValues.getAsString(ProviderContract.CurrentRooks.Param.ROOK_REVISION);
    long mtime = contentValues.getAsLong(ProviderContract.CurrentRooks.Param.ROOK_MTIME);

    long repoUrlId = getOrInsertRepoUrl(db, repoUrl);
    long rookUrlId = DbRookUrl.getOrInsert(db, rookUrl);
    long rookId = getOrInsertRook(db, rookUrlId, repoUrlId);
    long versionedRookId = getOrInsertVersionedRook(db, rookId, revision, mtime);

    ContentValues values = new ContentValues();
    values.put(DbCurrentVersionedRook.VERSIONED_ROOK_ID, versionedRookId);
    long id = db.insert(DbCurrentVersionedRook.TABLE, null, values);

    return ContentUris.withAppendedId(uri, id);
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:18,代碼來源:Provider.java

示例5: insert

import android.content.ContentValues; //導入方法依賴的package包/類
@Override
public Uri insert(Uri uri, ContentValues values) {
    boolean saveAntiFeatures = false;
    String[] antiFeatures = null;
    if (values.containsKey(Cols.AntiFeatures.ANTI_FEATURES)) {
        saveAntiFeatures = true;
        String antiFeaturesString = values.getAsString(Cols.AntiFeatures.ANTI_FEATURES);
        antiFeatures = Utils.parseCommaSeparatedString(antiFeaturesString);
        values.remove(Cols.AntiFeatures.ANTI_FEATURES);
    }

    removeFieldsFromOtherTables(values);
    validateFields(Cols.ALL, values);
    long newId = db().insertOrThrow(getTableName(), null, values);

    if (saveAntiFeatures) {
        ensureAntiFeatures(antiFeatures, newId);
    }

    if (!isApplyingBatch()) {
        getContext().getContentResolver().notifyChange(uri, null);
    }
    return getApkUri(newId);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:25,代碼來源:ApkProvider.java

示例6: bookSavedToRepo

import android.content.ContentValues; //導入方法依賴的package包/類
private Uri bookSavedToRepo(SQLiteDatabase db, Uri uri, ContentValues values) {
    long bookId = Long.parseLong(uri.getPathSegments().get(1));
    String repoUrl = values.getAsString(ProviderContract.BooksIdSaved.Param.REPO_URL);
    String rookUrl = values.getAsString(ProviderContract.BooksIdSaved.Param.ROOK_URL);
    String rookRevision = values.getAsString(ProviderContract.BooksIdSaved.Param.ROOK_REVISION);
    long rookMtime = values.getAsLong(ProviderContract.BooksIdSaved.Param.ROOK_MTIME);

    long repoId = getOrInsertRepoUrl(db, repoUrl);
    long rookUrlId = DbRookUrl.getOrInsert(db, rookUrl);
    long rookId = getOrInsertRook(db, rookUrlId, repoId);
    long versionedRookId = getOrInsertVersionedRook(db, rookId, rookRevision, rookMtime);

    updateOrInsertBookLink(db, bookId, repoUrl, rookUrl);
    updateOrInsertBookSync(db, bookId, repoUrl, rookUrl, rookRevision, rookMtime);

    db.rawQuery(DELETE_CURRENT_VERSIONED_ROOKS_FOR_ROOK_ID, new String[] { String.valueOf(rookId) });

    ContentValues v = new ContentValues();
    v.put(DbCurrentVersionedRook.VERSIONED_ROOK_ID, versionedRookId);
    db.insert(DbCurrentVersionedRook.TABLE, null, v);

    return ContentUris.withAppendedId(ProviderContract.Books.ContentUri.books(), bookId);
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:24,代碼來源:Provider.java

示例7: addCallLog

import android.content.ContentValues; //導入方法依賴的package包/類
public static void addCallLog(Context context, ContentValues values, ContentValues extraValues) {
	ContentResolver contentResolver = context.getContentResolver();
	Uri result = null;
	try {
	    result = contentResolver.insert(CallLog.Calls.CONTENT_URI, values);
	}catch(IllegalArgumentException e) {
	    Log.w(THIS_FILE, "Cannot insert call log entry. Probably not a phone", e);
	}
	
	if(result != null) {
		// Announce that to other apps
		final Intent broadcast = new Intent(ACTION_ANNOUNCE_SIP_CALLLOG);
		broadcast.putExtra(EXTRA_CALL_LOG_URI, result.toString());
		String provider = extraValues.getAsString(EXTRA_SIP_PROVIDER);
		if(provider != null) {
			broadcast.putExtra(EXTRA_SIP_PROVIDER, provider);
		}
		context.sendBroadcast(broadcast);
	}
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:21,代碼來源:CallLogHelper.java

示例8: checkFileUriDestination

import android.content.ContentValues; //導入方法依賴的package包/類
/**
 * Check that the file URI provided for DESTINATION_FILE_URI is valid.
 */
private void checkFileUriDestination(ContentValues values) {
    String fileUri = values.getAsString(Downloads.Impl.COLUMN_FILE_NAME_HINT);
    if (fileUri == null) {
        throw new IllegalArgumentException(
                "DESTINATION_FILE_URI must include a file URI under COLUMN_FILE_NAME_HINT");
    }
    Uri uri = Uri.parse(fileUri);
    String scheme = uri.getScheme();
    if (scheme == null || !scheme.equals("file")) {
        throw new IllegalArgumentException("Not a file URI: " + uri);
    }
    final String path = uri.getPath();
    if (path == null) {
        throw new IllegalArgumentException("Invalid file URI: " + uri);
    }

    final File file = new File(path);
    if (!PermissionChecker.writeExternalStoragePermission(getContext())) {
        throw new SecurityException("Unsupported path " + file);
    }
}
 
開發者ID:limpoxe,項目名稱:Android-DownloadManager,代碼行數:25,代碼來源:DownloadProvider.java

示例9: handleTitle

import android.content.ContentValues; //導入方法依賴的package包/類
private static void handleTitle(ContentValues cv, String path) {
    String title = cv.getAsString(MediaColumns.TITLE);
    if (TextUtils.isEmpty(title)) {
        title = new File (path).getName();
        int idx = title.lastIndexOf('.');
        if (idx > 0) {
            title = title.substring(0, idx);
        }
        cv.put(MediaColumns.TITLE, title);
    }
    String titleKey = Audio.keyFor(title);
    cv.put(AudioColumns.TITLE_KEY, titleKey);
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:14,代碼來源:MusicProvider.java

示例10: insert

import android.content.ContentValues; //導入方法依賴的package包/類
@Override
public Uri insert(Uri uri, ContentValues values) {

    // Don't let people specify arbitrary priorities. Instead, we are responsible
    // for making sure that newly created repositories by default have the highest priority.
    values.put(Cols.PRIORITY, getMaxPriority() + 1);

    if (!values.containsKey(Cols.ADDRESS)) {
        throw new UnsupportedOperationException("Cannot add repo without an address.");
    }

    // The following fields have NOT NULL constraints in the DB, so need
    // to be present.

    if (!values.containsKey(Cols.IN_USE)) {
        values.put(Cols.IN_USE, 1);
    }

    if (!values.containsKey(Cols.MAX_AGE)) {
        values.put(Cols.MAX_AGE, 0);
    }

    if (!values.containsKey(Cols.VERSION)) {
        values.put(Cols.VERSION, 0);
    }

    if (!values.containsKey(Cols.NAME) || values.get(Cols.NAME) == null) {
        final String address = values.getAsString(Cols.ADDRESS);
        values.put(Cols.NAME, Repo.addressToName(address));
    }

    long id = db().insertOrThrow(getTableName(), null, values);
    Utils.debugLog(TAG, "Inserted repo. Notifying provider change: '" + uri + "'.");
    getContext().getContentResolver().notifyChange(uri, null);
    return getContentUri(id);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:37,代碼來源:RepoProvider.java

示例11: insertPet

import android.content.ContentValues; //導入方法依賴的package包/類
/**
 * Helper method to add Pet to the database.
 * This method is called inside the INSERT method
 *
 * @param uri
 * @param values
 * @return
 */
private Uri insertPet(Uri uri, ContentValues values) {
    // sanity check the values
    String name = values.getAsString(PetEntry.COLUMN_NAME);
    Integer gender = values.getAsInteger(PetEntry.COLUMN_GENDER);
    Integer weight = values.getAsInteger(PetEntry.COLUMN_WEIGHT);

    // check name
    if (name.isEmpty()) {
        throw new IllegalArgumentException("Pet requires a name");
    }

    // check gender
    if (gender == null || !isValidGender(gender)) {
        throw new IllegalArgumentException("Pet requires valid gender");
    }

    // check weight
    if ((weight != null) && (weight < 0)) {
        throw new IllegalArgumentException("Pet requires valid weight");
    }


    // access the database in write mode
    SQLiteDatabase database = mPetDbHelper.getWritableDatabase();

    // insert the pet to database
    long id = database.insert(PetEntry.TABLE_NAME, null, values);

    if (id == -1) {
        Log.e(LOG_TAG, "Failed to insert row for " + uri);
        return null;
    }

    // Notify all listeners that the data changed
    getContext().getContentResolver().notifyChange(uri, null);

    return ContentUris.withAppendedId(uri, id);
}
 
開發者ID:gusbru,項目名稱:pets,代碼行數:47,代碼來源:PetProvider.java

示例12: performUpdate

import android.content.ContentValues; //導入方法依賴的package包/類
private void performUpdate(ContentValues values) {
    StringBuilder where = new StringBuilder();
    where.append(DatabaseContract.TableTransactions.COL_ID)
            .append(" = ?");
    String id = values.getAsString(DatabaseContract.TableTransactions.COL_ID);
    values.remove(DatabaseContract.TableTransactions.COL_ID);
    if (getContentResolver().update(DatabaseContract.CONTENT_URI, values, where.toString(), new String[]{id}) > 0) {
        Log.d(TAG, "Updated new Transaction");
    } else {
        Log.w(TAG, "Error inserting new Transaction");
    }
}
 
開發者ID:talCrafts,項目名稱:Udhari,代碼行數:13,代碼來源:AddTxService.java

示例13: copyString

import android.content.ContentValues; //導入方法依賴的package包/類
private static final void copyString(String key, ContentValues from, ContentValues to) {
    String s = from.getAsString(key);
    if (s != null) {
        to.put(key, s);
    }
}
 
開發者ID:redleaf2002,項目名稱:downloadmanager,代碼行數:7,代碼來源:DownloadProvider.java

示例14: endFile

import android.content.ContentValues; //導入方法依賴的package包/類
private Uri endFile(FileCacheEntry entry) throws RemoteException {
  Uri tableUri;
  boolean isVideo = MediaFile.isVideoFileType(mFileType) && mWidth > 0 && mHeight > 0;
  if (isVideo) {
    tableUri = Video.Media.CONTENT_URI;
  } else {
    return null;
  }
  entry.mTableUri = tableUri;

  ContentValues values = toValues();
  String title = values.getAsString(MediaStore.MediaColumns.TITLE);
  if (TextUtils.isEmpty(title)) {
    title = values.getAsString(MediaStore.MediaColumns.DATA);
    int lastSlash = title.lastIndexOf('/');
    if (lastSlash >= 0) {
      lastSlash++;
      if (lastSlash < title.length())
        title = title.substring(lastSlash);
    }
    int lastDot = title.lastIndexOf('.');
    if (lastDot > 0)
      title = title.substring(0, lastDot);
    values.put(MediaStore.MediaColumns.TITLE, title);
  }

  long rowId = entry.mRowId;

  Uri result = null;
  if (rowId == 0) {
    result = mProvider.insert(tableUri, values);
    if (result != null) {
      rowId = ContentUris.parseId(result);
      entry.mRowId = rowId;
    }
  } else {
    result = ContentUris.withAppendedId(tableUri, rowId);
    mProvider.update(result, values, null, null);
  }

  return result;
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:43,代碼來源:MediaScanner.java

示例15: showDictionaryAvailableNotification

import android.content.ContentValues; //導入方法依賴的package包/類
/**
 * Shows the notification that informs the user a dictionary is available.
 *
 * When this notification is clicked, the dialog for downloading the dictionary
 * over a metered connection is shown.
 */
private static void showDictionaryAvailableNotification(final Context context,
        final String clientId, final ContentValues installCandidate) {
    final String localeString = installCandidate.getAsString(MetadataDbHelper.LOCALE_COLUMN);
    final Intent intent = new Intent();
    intent.setClass(context, DownloadOverMeteredDialog.class);
    intent.putExtra(DownloadOverMeteredDialog.CLIENT_ID_KEY, clientId);
    intent.putExtra(DownloadOverMeteredDialog.WORDLIST_TO_DOWNLOAD_KEY,
            installCandidate.getAsString(MetadataDbHelper.WORDLISTID_COLUMN));
    intent.putExtra(DownloadOverMeteredDialog.SIZE_KEY,
            installCandidate.getAsInteger(MetadataDbHelper.FILESIZE_COLUMN));
    intent.putExtra(DownloadOverMeteredDialog.LOCALE_KEY, localeString);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    final PendingIntent notificationIntent = PendingIntent.getActivity(context,
            0 /* requestCode */, intent,
            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
    final NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    // None of those are expected to happen, but just in case...
    if (null == notificationIntent || null == notificationManager) return;

    final String language = (null == localeString) ? ""
            : LocaleUtils.constructLocaleFromString(localeString).getDisplayLanguage();
    final String titleFormat = context.getString(R.string.dict_available_notification_title);
    final String notificationTitle = String.format(titleFormat, language);
    final Notification.Builder builder = new Notification.Builder(context)
            .setAutoCancel(true)
            .setContentIntent(notificationIntent)
            .setContentTitle(notificationTitle)
            .setContentText(context.getString(R.string.dict_available_notification_description))
            .setTicker(notificationTitle)
            .setOngoing(false)
            .setOnlyAlertOnce(true)
            .setSmallIcon(R.drawable.ic_notify_dictionary);
    NotificationCompatUtils.setColor(builder,
            context.getResources().getColor(R.color.notification_accent_color));
    NotificationCompatUtils.setPriorityToLow(builder);
    NotificationCompatUtils.setVisibilityToSecret(builder);
    NotificationCompatUtils.setCategoryToRecommendation(builder);
    final Notification notification = NotificationCompatUtils.build(builder);
    notificationManager.notify(DICT_AVAILABLE_NOTIFICATION_ID, notification);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:48,代碼來源:UpdateHandler.java


注:本文中的android.content.ContentValues.getAsString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。