当前位置: 首页>>代码示例>>Java>>正文


Java ContentUris.withAppendedId方法代码示例

本文整理汇总了Java中android.content.ContentUris.withAppendedId方法的典型用法代码示例。如果您正苦于以下问题:Java ContentUris.withAppendedId方法的具体用法?Java ContentUris.withAppendedId怎么用?Java ContentUris.withAppendedId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ContentUris的用法示例。


在下文中一共展示了ContentUris.withAppendedId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareEditContactIntentWithSipAddress

import android.content.ContentUris; //导入方法依赖的package包/类
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipUri) {
	Intent intent = new Intent(Intent.ACTION_EDIT, Contacts.CONTENT_URI);
	Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
	intent.setData(contactUri);
	
	ArrayList<ContentValues> data = new ArrayList<ContentValues>();
	ContentValues sipAddressRow = new ContentValues();
	sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
	sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
	data.add(sipAddressRow);
	intent.putParcelableArrayListExtra(Insert.DATA, data);
	
	return intent;
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:15,代码来源:ApiElevenPlus.java

示例2: deleteCalendar

import android.content.ContentUris; //导入方法依赖的package包/类
@SuppressWarnings("MissingPermission") // already requested in calling method
public void deleteCalendar(String calendarName) {
    try {
        Uri evuri = CalendarContract.Calendars.CONTENT_URI;
        final ContentResolver contentResolver = cordova.getActivity().getContentResolver();
        Cursor result = contentResolver.query(evuri, new String[]{CalendarContract.Calendars._ID, CalendarContract.Calendars.NAME, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME}, null, null, null);
        if (result != null) {
            while (result.moveToNext()) {
                if (result.getString(1).equals(calendarName) || result.getString(2).equals(calendarName)) {
                    long calid = result.getLong(0);
                    Uri deleteUri = ContentUris.withAppendedId(evuri, calid);
                    contentResolver.delete(deleteUri, null, null);
                }
            }
            result.close();
        }

        // also delete previously crashing calendars, see https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin/issues/241
        deleteCrashingCalendars(contentResolver);
    } catch (Throwable t) {
        System.err.println(t.getMessage());
        t.printStackTrace();
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:25,代码来源:AbstractCalendarAccessor.java

示例3: updateDatabase

import android.content.ContentUris; //导入方法依赖的package包/类
/**
 * Updates the database if that is required (title and/or hide)
 */
public void updateDatabase(ContentResolver cr) {
    boolean updateTitle = false;
    if (dvdPart == 1) { // we only ever change the name of the _1.vob
        if (newTitle == null) {
            // reset title back to null if it is not.
            updateTitle =  archosTitle != null;
        } else if (!newTitle.equals(archosTitle)) {
            // change title to something new.
            updateTitle = true;
        }
    }
    if (updateTitle || hidden != newHide) {
        ContentValues cv = new ContentValues();
        if (updateTitle) {
            cv.put(VideoStore.Video.VideoColumns.ARCHOS_TITLE, newTitle);
            if (DBG) Log.d(TAG, "update " + file + " title: " + newTitle);
        }
        if (hidden != newHide) {
            cv.put(VideoStore.Video.VideoColumns.ARCHOS_HIDE_FILE, newHide ? "1" : "0");
            if (DBG) Log.d(TAG, "update " + file + " hide: " + (newHide ? "1" : "0"));
        }
        Uri uri = ContentUris.withAppendedId(VideoStore.Video.Media.EXTERNAL_CONTENT_URI, id);
        cr.update(uri, cv, null, null);
    }
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:29,代码来源:VobHandler.java

示例4: handleImageOnKitKat

import android.content.ContentUris; //导入方法依赖的package包/类
@TargetApi(19)
private void handleImageOnKitKat(Intent data){

    String imagePath=null;
    Uri uri=data.getData();
    if (DocumentsContract.isDocumentUri(getActivity(),uri)){
        //如果是 document 类型的 Uri,则通过document id处理
        String docId=DocumentsContract.getDocumentId(uri);
        if ("com.android.providers.media.documents".equals(uri.getAuthority())){
            String id=docId.split(":")[1];    //解析出数字格式的id
            String selection=MediaStore.Images.Media._ID+"="+id;
            imagePath=getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
        }else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())){
            Uri contentUri= ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
                    Long.valueOf(docId));
            imagePath=getImagePath(contentUri,null);
        }
    }else if ("content".equalsIgnoreCase(uri.getScheme())){
        //如果是content类型的Uri 则使用普通方式处理
        imagePath=getImagePath(uri,null);
    }else if ("file".equalsIgnoreCase(uri.getScheme())){
        //如果是file类型的Uri,直接获取图片路径即可
        imagePath=uri.getPath();
    }
    displayImage(imagePath);      //根据图片路径显示图片
}
 
开发者ID:android-jian,项目名称:topnews,代码行数:27,代码来源:SettingFragment.java

示例5: insert

import android.content.ContentUris; //导入方法依赖的package包/类
public Uri insert(Uri uri, ContentValues values){
    db = tOpenHelper.getWritableDatabase();
    long id;
    switch(sUriMatcher.match(uri)){
        case ENTRY_LIST:
            id = db.insert(TodoEntry.TABLE_NAME, null, values);
            break;
        case LABEL_LIST:
            id = db.insert(TodoLabel.TABLE_NAME, null, values);
            break;
        case NOTIFICATION_LIST:
            id = db.insert(TodoNotification.TABLE_NAME, null, values);
            break;
        default:
            throw new IllegalArgumentException("Unsupported URI for insertion: " + uri);
    }
    Uri itemUri = ContentUris.withAppendedId(uri, id);
    getContext().getContentResolver().notifyChange(itemUri, null);
    return itemUri;
}
 
开发者ID:danlls,项目名称:Todule-android,代码行数:21,代码来源:ToduleProvider.java

示例6: getContactInfo

import android.content.ContentUris; //导入方法依赖的package包/类
@Override
public ContactInfo getContactInfo(Context context, Cursor cursor) {
    ContactInfo ci = new ContactInfo();
    // Get values
    ci.displayName = cursor.getString(cursor.getColumnIndex(Contacts.DISPLAY_NAME));
    ci.contactId = cursor.getLong(cursor.getColumnIndex(Contacts._ID));
    ci.callerInfo.contactContentUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, ci.contactId);
    ci.callerInfo.photoId = cursor.getLong(cursor.getColumnIndex(Contacts.PHOTO_ID));
    int photoUriColIndex = cursor.getColumnIndex(Contacts.PHOTO_ID);
    ci.status = cursor.getString(cursor.getColumnIndex(Contacts.CONTACT_STATUS));
    ci.presence = cursor.getInt(cursor.getColumnIndex(Contacts.CONTACT_PRESENCE));

    if (photoUriColIndex >= 0) {
        String photoUri = cursor.getString(photoUriColIndex);
        if (!TextUtils.isEmpty(photoUri)) {
            ci.callerInfo.photoUri = Uri.parse(photoUri);
        }
    }
    ci.hasPresence = !TextUtils.isEmpty(ci.status);
    return ci;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:22,代码来源:ContactsUtils5.java

示例7: getSongCountForAlbumInt

import android.content.ContentUris; //导入方法依赖的package包/类
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;
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:23,代码来源:MusicPlayer.java

示例8: preHoneycombGetContactInfo

import android.content.ContentUris; //导入方法依赖的package包/类
/**
 * For versions before Honeycomb, we get all the contact info from the same table.
 */
public void preHoneycombGetContactInfo(Cursor cursor) {
  if (cursor.moveToFirst()) {
    contactName = guardCursorGetString(cursor, NAME_INDEX);
    phoneNumber = guardCursorGetString(cursor, NUMBER_INDEX);
    int contactId = cursor.getInt(PERSON_INDEX);
    Uri cUri = ContentUris.withAppendedId(Contacts.People.CONTENT_URI, contactId);
    contactPictureUri = cUri.toString();
    String emailId = guardCursorGetString(cursor, EMAIL_INDEX);
    emailAddress = getEmailAddress(emailId);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:15,代码来源:PhoneNumberPicker.java

示例9: onListItemClick

import android.content.ContentUris; //导入方法依赖的package包/类
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Uri noteUri = ContentUris.withAppendedId(getIntent().getData(), id);
    
    String action = getIntent().getAction();
    if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) {
        // The caller is waiting for us to return a note selected by
        // the user.  The have clicked on one, so return it now.
        setResult(RESULT_OK, new Intent().setData(noteUri));
    } else {
        // Launch activity to view/edit the currently selected item
        startActivity(new Intent(Intent.ACTION_EDIT, noteUri));
    }
}
 
开发者ID:firebase,项目名称:firebase-testlab-instr-lib,代码行数:15,代码来源:NotesList.java

示例10: getContentUriForImageFromMediaStore

import android.content.ContentUris; //导入方法依赖的package包/类
private static Uri getContentUriForImageFromMediaStore(Context context, String path) {
    ContentResolver resolver = context.getContentResolver();
    //Uri photoUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
    // to handle hidden images
    Uri photoUri = MediaStore.Files.getContentUri("external");
    Cursor cursor = resolver.query(photoUri,
            new String[]{BaseColumns._ID},
            MediaStore.MediaColumns.DATA + " = ?",
            new String[]{path}, null);
    if (cursor == null) {
        return Uri.parse(path);
    }
    cursor.moveToFirst();
    if (cursor.isAfterLast()) {
        cursor.close();
        // insert system media db
        ContentValues values = new ContentValues();
        values.put(MediaStore.Images.Media.DATA, path);
        values.put(MediaStore.Images.Media.MIME_TYPE, MediaType.getMimeType(path));
        return context.getContentResolver().insert(photoUri, values);
    } else {
        long id = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID));
        Uri uri = ContentUris.withAppendedId(photoUri, id);
        cursor.close();
        return uri;
    }
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:28,代码来源:StorageUtil.java

示例11: createUri

import android.content.ContentUris; //导入方法依赖的package包/类
public synchronized Uri createUri(@NonNull byte[] blob) {
  try {
    long id = Math.abs(SecureRandom.getInstance("SHA1PRNG").nextLong());
    cache.put(id, blob);

    Uri uniqueUri = Uri.withAppendedPath(CONTENT_URI, String.valueOf(System.currentTimeMillis()));
    return ContentUris.withAppendedId(uniqueUri, id);
  } catch (NoSuchAlgorithmException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:12,代码来源:SingleUseBlobProvider.java

示例12: notifyContentChanged

import android.content.ContentUris; //导入方法依赖的package包/类
/**
 * Notify of a change through both URIs (/my_downloads and /all_downloads)
 *
 * @param uri      either URI for the changed download(s)
 * @param uriMatch the match ID from {@link #sURIMatcher}
 */
private void notifyContentChanged(final Uri uri, int uriMatch) {
    Long downloadId = null;
    if (uriMatch == MY_DOWNLOADS_ID || uriMatch == ALL_DOWNLOADS_ID) {
        downloadId = Long.parseLong(getDownloadIdFromUri(uri));
    }
    for (Uri uriToNotify : BASE_URIS) {
        if (downloadId != null) {
            uriToNotify = ContentUris.withAppendedId(uriToNotify, downloadId);
        }
        getContext().getContentResolver().notifyChange(uriToNotify, null);
    }
}
 
开发者ID:redleaf2002,项目名称:downloadmanager,代码行数:19,代码来源:DownloadProvider.java

示例13: insert

import android.content.ContentUris; //导入方法依赖的package包/类
@Override
public Uri insert(@NonNull Uri uri, ContentValues values) {
    // COMPLETED (1) Get access to the task database (to write new data to)
    final SQLiteDatabase db = mTaskDbHelper.getWritableDatabase();

    // COMPLETED (2) Write URI matching code to identify the match for the tasks directory
    int match = sUriMatcher.match(uri);
    Uri returnUri;

    switch (match) {
        case TASKS:
            // COMPLETED (3) Insert new values into the database
            long id = db.insert(TaskEntry.TABLE_NAME, null, values);
            if (id > 0) {
                returnUri = ContentUris.withAppendedId(TaskEntry.CONTENT_URI, id);
            } else {
                throw new SQLException("Failed to insert row " + uri);
            }
            break;
        // COMPLETED (4) Set the value for the returnedUri and write the default case for unknown URI's
        default:
            throw new UnsupportedOperationException("Unknown uri: " + uri);
    }

    // COMPLETED (5) Notify the resolver if the uri has been changed, and return the newly inserted URI
    getContext().getContentResolver().notifyChange(uri, null);

    return returnUri;
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:30,代码来源:TaskContentProvider.java

示例14: onCreate

import android.content.ContentUris; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle bundle = this.getArguments();
    if(bundle != null){
        mode = bundle.getString("mode");
        if(bundle.containsKey("entry_id")){
            entryId = bundle.getLong("entry_id");
        } else {
            entryId = null;
        }
    }

    if(savedInstanceState != null){
        myCalendar = (Calendar) savedInstanceState.getSerializable("calendar");
        chosenLabelId = savedInstanceState.getLong("chosen_label_id", -1L);
        title = savedInstanceState.getString("title");
    } else {
        myCalendar = Calendar.getInstance();
        // Default for new entry
        myCalendar.set(Calendar.HOUR_OF_DAY, 23);
        myCalendar.set(Calendar.MINUTE, 59);
        myCalendar.set(Calendar.SECOND, 0);

        if (mode.equals("edit_entry")){
            Uri entryUri = ContentUris.withAppendedId(ToduleDBContract.TodoEntry.CONTENT_ID_URI_BASE, entryId);
            Cursor cr = getContext().getContentResolver().query(entryUri, TodoEntry.PROJECTION_ALL, null, null, TodoEntry.SORT_ORDER_DEFAULT);
            cr.moveToFirst();

            long dueDateInMillis = cr.getLong(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_DUE_DATE));
            title = cr.getString(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_TITLE));
            description = cr.getString(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_DESCRIPTION));
            if(cr.isNull(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_LABEL))){
                chosenLabelId = -1L;
            } else{
                chosenLabelId = cr.getLong(cr.getColumnIndexOrThrow(TodoEntry.COLUMN_NAME_LABEL));
            }

            myCalendar.setTimeInMillis(dueDateInMillis);

            cr.close();
        }
    }
}
 
开发者ID:danlls,项目名称:Todule-android,代码行数:46,代码来源:ToduleAddFragment.java

示例15: getSongFileUri

import android.content.ContentUris; //导入方法依赖的package包/类
public static Uri getSongFileUri(int songId) {
    return ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, songId);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:4,代码来源:MusicUtil.java


注:本文中的android.content.ContentUris.withAppendedId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。