
org.robolectric.shadows.ShadowContentUris Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.shadows;
import android.content.ContentUris;
import android.net.Uri;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
@Implements(ContentUris.class)
public class ShadowContentUris {
@Implementation
public static Uri withAppendedId(Uri contentUri, long id) {
return Uri.withAppendedPath(contentUri, String.valueOf(id));
}
@Implementation
public static long parseId(Uri contentUri) {
if (!contentUri.isHierarchical()) {
throw new UnsupportedOperationException();
}
String path = contentUri.getLastPathSegment();
if (path == null) return -1;
return Long.parseLong(path);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy