Uri uri = Uri.parse("content://downloads/my_downloads/image123.jpg"); String fileName = uri.getLastPathSegment(); //fileName: image123.jpg
Uri uri = Uri.parse("content://myapp/books/123"); String bookId = uri.getLastPathSegment(); //bookId: 123Here, we have a content Uri that refers to a book resource with ID "123". By calling getLastPathSegment(), we can extract the ID as a string. Package library: android.net