private Table(Builder builder) { mUri = builder.mUri; mProjection = builder.mProjection; mTableName = builder.mTableName; if (mTableName == null) { mTableName = mUri.getLastPathSegment(); } }
@Override public Cursor query(Uri uri) { String videoId = uri.getLastPathSegment(); return contentResolver.query( MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, PATH_PROJECTION, PATH_SELECTION, new String[] {videoId}, null /*sortOrder*/); } }
@Override public Cursor query(Uri uri) { String imageId = uri.getLastPathSegment(); return contentResolver.query( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, PATH_PROJECTION, PATH_SELECTION, new String[] {imageId}, null /*sortOrder*/); } }
protected String getFileName(Uri uri) { return(uri.getLastPathSegment()); }
protected String getFileName(Uri uri) { return(uri.getLastPathSegment()); }
protected String getFileName(Uri uri) { return(uri.getLastPathSegment()); }
private static String getContactIdFromContactUri(Uri contactUri) { return contactUri.getLastPathSegment(); }
import android.net.Uri; Uri uri = Uri.parse("http://example.com/foo/bar/42?param=true"); String token = uri.getLastPathSegment();
private String generateLocalTempFileName(Uri uri) { return "temp_" + uri.getLastPathSegment() + "_" + System.currentTimeMillis(); }
@Implementation protected static long parseId(Uri contentUri) { if (!contentUri.isHierarchical()) { throw new UnsupportedOperationException(); } String path = contentUri.getLastPathSegment(); if (path == null) return -1; return Long.parseLong(path); } }
public static String getDataUriId(@NonNull Intent intent, String altParamId) { if (intent.getData() == null) { return null; } if (TextUtils.equals(intent.getData().getScheme(), BuildConfig.APPLICATION_ID)) { return intent.getData().getLastPathSegment(); } else { // web URI return intent.getData().getQueryParameter(altParamId); } }
/** Returns a fixed SmoothStreaming client manifest {@link Uri}. */ public static Uri fixManifestUri(Uri manifestUri) { if (Util.toLowerInvariant(manifestUri.getLastPathSegment()).matches("manifest(\\(.+\\))?")) { return manifestUri; } return Uri.withAppendedPath(manifestUri, "Manifest"); }
// get calendar Calendar cal = Calendar.getInstance(); Uri EVENTS_URI = Uri.parse(getCalendarUriBase(this) + "events"); ContentResolver cr = getContentResolver(); // event insert ContentValues values = new ContentValues(); values.put("calendar_id", 1); values.put("title", "Reminder Title"); values.put("allDay", 0); values.put("dtstart", cal.getTimeInMillis() + 11*60*1000); // event starts at 11 minutes from now values.put("dtend", cal.getTimeInMillis()+60*60*1000); // ends 60 minutes from now values.put("description", "Reminder description"); values.put("visibility", 0); values.put("hasAlarm", 1); Uri event = cr.insert(EVENTS_URI, values); // reminder insert Uri REMINDERS_URI = Uri.parse(getCalendarUriBase(this) + "reminders"); values = new ContentValues(); values.put( "event_id", Long.parseLong(event.getLastPathSegment())); values.put( "method", 1 ); values.put( "minutes", 10 ); cr.insert( REMINDERS_URI, values );
/** * Retrieves {@link InputStream} of image by URI (image is accessed using {@link ContentResolver}). * * @param imageUri Image URI * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object) * DisplayImageOptions.extraForDownloader(Object)}; can be null * @return {@link InputStream} of image * @throws FileNotFoundException if the provided URI could not be opened */ protected InputStream getStreamFromContent(String imageUri, Object extra) throws FileNotFoundException { ContentResolver res = context.getContentResolver(); Uri uri = Uri.parse(imageUri); if (isVideoContentUri(uri)) { // video thumbnail Long origId = Long.valueOf(uri.getLastPathSegment()); Bitmap bitmap = MediaStore.Video.Thumbnails .getThumbnail(res, origId, MediaStore.Images.Thumbnails.MINI_KIND, null); if (bitmap != null) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(CompressFormat.PNG, 0, bos); return new ByteArrayInputStream(bos.toByteArray()); } } else if (imageUri.startsWith(CONTENT_CONTACTS_URI_PREFIX)) { // contacts photo return getContactPhotoStream(uri); } return res.openInputStream(uri); }
void addDocument(Uri document) { add(new SimplePageDescriptor(document.toString(), document.getLastPathSegment())); }
@Override public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException { String[] netProjection= netProjection(projection, SUPPORTED_DOCUMENT_PROJECTION); MatrixCursor result=new MatrixCursor(netProjection); try { addDocumentRow(result, Uri.parse(documentId).getLastPathSegment(), documentId); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Exception reading asset dir", e); } return(result); }
private JSONObject getTemplateFromUri(Uri uri, Collection col) throws JSONException { JSONObject model = col.getModels().get(getModelIdFromUri(uri, col)); Integer ord = Integer.parseInt(uri.getLastPathSegment()); return model.getJSONArray("tmpls").getJSONObject(ord); }
@Override public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { ParcelFileDescriptor[] pipe=null; try { pipe=ParcelFileDescriptor.createPipe(); AssetManager assets=getContext().getAssets(); new TransferThread(assets.open(uri.getLastPathSegment()), new AutoCloseOutputStream(pipe[1])).start(); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Exception opening pipe", e); throw new FileNotFoundException("Could not open pipe for: " + uri.toString()); } return(pipe[0]); }
private Uri create(HttpTransaction transaction) { ContentValues values = LocalCupboard.getInstance().withEntity(HttpTransaction.class).toContentValues(transaction); Uri uri = context.getContentResolver().insert(ChuckContentProvider.TRANSACTION_URI, values); transaction.setId(Long.valueOf(uri.getLastPathSegment())); if (showNotification) { notificationHelper.show(transaction); } retentionManager.doMaintenance(); return uri; }
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder(); int uriType = sURIMatcher.match(uri); switch (uriType) { case SIMPLEENTITY_DIR: queryBuilder.setTables(TABLENAME); break; case SIMPLEENTITY_ID: queryBuilder.setTables(TABLENAME); queryBuilder.appendWhere(PK + "=" + uri.getLastPathSegment()); break; default: throw new IllegalArgumentException("Unknown URI: " + uri); } Database db = getDatabase(); Cursor cursor = queryBuilder.query(((StandardDatabase) db).getSQLiteDatabase(), projection, selection, selectionArgs, null, null, sortOrder); cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor; }